
Suppose you have a employee table with colums
EmpID, Name,Address,Designation....
Your requirement is....
In the page load you want to show the names in the dropdownlist and when selecting a name all the details of that employee should be listed in the listitem...
Try this....
in aspx..
<asp:DropDownList ID="ddl1" runat="server" AutoPostBack="true"
onselectedindexchanged="ddl1_SelectedIndexChanged">
</asp:DropDownList>
in the page load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Retreive the result set in DataSet ds;
//assume that you know how to get the resultset of a table in the dataset using ado.net
//Query -"SELECT * from employee"
so,
DataSet ds =The ResultSet of your query;
ddl1.DataSource = ds;
ddl1.DataTextField = "Name";
ddl1.DataValueField = "EmpID";
ddlCategory.DataBind();
//So in this way you can show the names in the dropdownlist
}
}
Nitha Deepak
Akiii, if this helps please login to Mark As Answer. | Alert Moderator