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);
}
}