Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Using Controls placed in the DataList


Message #1 by "Soha Sobhy" <zee_alien@h...> on Thu, 6 Feb 2003 13:57:35
Hello,
I have a number of server controls inside my datalist and I wanted to get 
data from them using the code below, but both the textbox and the 
dropdownlist always return their default values. Can anyone please help 
me with that? Thanks.

private void OrderButton_Click(object sender, System.EventArgs e)
{
	for(int i=0;i<DataList1.Items.Count;i++)
		{
			Label CurrentLabel=(Label)DataList1.Items
[i].FindControl("MedIDLabel");
			string Med=CurrentLabel.Text;
			TextBox CurrentBox=(TextBox)DataList1.Items
[i].FindControl("TextBox1");
			string strQuant=CurrentBox.Text;
			DropDownList Current=(DropDownList)DataList1.Items
[i].FindControl("DropDownList1");
			string Val=Current.SelectedItem.Text;
			Response.Write(Med);
				
			Response.Write(strQuant);
			
			Response.Write(Val);
		}
}

  Return to Index