Reputation: 71
I'm newbie in c# and not familiar with its syntax. Need some help here. I would want to retrieve database data into my dropdownlist. How can i replace the following textbox for dropdownlist?
This is my dropdownlist:
<asp:DropDownList ID="DropDownList1" runat="server" OnClick="btnFilterID_Click"></asp:DropDownList>
This is the loop to retriev textbox.
foreach (System.Data.DataRow row in dt.Rows)
{
txtFname.Text = row["f_name"].ToString();
}
Upvotes: 0
Views: 87
Reputation: 1803
in your .cs
foreach (System.Data.DataRow row in dt.Rows)
{
DropDownList1.Items.Add(row["f_name"].ToString());
}
Upvotes: 1