C Sharp | Development | Web
Load data into controls in asp.net
Usually when working on windows form, I use this to do the work
DropDownList1.DataSource = new ApplicationTableAdapter().GetDataBySystemID(1); DropDownList1.DataTextField = "Name"; DropDownList1.DataValueField = "ID";
But surprisingly, when switched to ASP.NET, the above code no longer works, at first I thought it was a problem with the paradigm so I tried to store the data as a session variable but that didn’t work either, until I tried this
DropDownList1.DataSource = new ApplicationTableAdapter().GetDataBySystemID(1); DropDownList1.DataTextField = "Name"; DropDownList1.DataValueField = "ID"; DropDownList1.DataBind();
One extra line.