How can I make if I choose Yes , the value to be saved in the dropdown everythime I click edit ?
I know I asked once and I used if selected value = 0 ( Yes ) //my code will execute but it's not bringing Yet at the top ,
DropDownList id = (DropDownList)sender;
GridViewRow row = GridView1.Rows[GridView1.EditIndex];
if (id.SelectedIndex == 1)
{
((BoundField)GridView1.Columns[5]).ReadOnly = false;
((BoundField)GridView1.Columns[6]).ReadOnly = false;
}
if (id.SelectedIndex == 0)
{
((BoundField)GridView1.Columns[5]).ReadOnly = true;
((BoundField)GridView1.Columns[6]).ReadOnly = true;
}
Try to set data source for dropdownlist only once on GET request. This issue happens cause you set data source everytime and you didn't persist selected item information.
protected override OnLoad(object sender, EventArgs e)
{
if (!IsPostBack)
{
Ddl.DataSource = new DataSource();
DdlIssues.DataBind();
}
}
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.