i have a dropdown control in form lets say it as dropdown1
on button click i need full row of binded table to row
page_load()
{
dropdown1.DataSource = datatable1;
}
dropdown1_selectedIndexChange()
{
DataRow dRow1 = datatable1. row of selectedValue //Corresponding row of selected item with out calling select again to database
}
tried google a lot but did not found any suitable solution
Please check following coding it's worked. Use Select
method of data table for filtering row
public static DataTable dt = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// This is my data source
dt= TagController.TagSelect(-1, -1, "", "").Tables[0];
ddlQuestions.DataSource = dt;
ddlQuestions.DataValueField = "Id";
ddlQuestions.DataTextField = "Name";
ddlQuestions.DataBind();
}
}
protected void ddlQuestions_SelectedIndexChanged(object sender, EventArgs e)
{
DataRow dr = dt.Select("Id=" + ddlQuestions.SelectedValue)[0];
Response.Write(dr["Description"].ToString());
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.