How to popluat value form database into combo box using Asp.net
I want to fetch list of students into combo bo开发者_开发百科x and on the base of combo box slection I will fetch their related record into another grid. please guide me regarding this task.
You can bind DropDownList as below
DropDownList1.DataSource=GetStudentDataSet();
DropDownList1.DataTextField="StudentName";
DropDownList1.DataValueField="StudentID";
DropDownList1.DataBind();
Put GridView bind code on selected change event of DropDownList as below
void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
//Fecth selected student id
int studentId = Convert.ToInt32(DropDownList1.SelectedValue);
//Bind Grdivew
}
精彩评论