G
Guest
I have a Datagrid and it has a dropdown.
<aspropDownList DataSource="<%# PopulateList() %>" OnLoad="SelectIndex" >
I assign selected index of the my dropdown in SelectIndex function.
protected void SelectIndex(object source, System.EventArgs e)
{
DropDownList DXmlFirmalar = (DropDownList)source;
DataSet ds = (DataSet)DataGrid1.DataSource;
DataTable tb=ds.Tables[0];
DataRow row = tb.Rows[DataGrid1.EditItemIndex];
////////////////////////////
///
SqlConnection baglantim=con.MyConnect ();
DataSet ds1=new DataSet ();
ds1=con.GetFirmalar(baglantim);
int y=0;
foreach (DataRow item in ds1.Tables[0].Rows )
{
if (row["XmlFirmalar"].Equals(item["Firma_ID"].ToString()))
DXmlFirmalar.SelectedIndex=y;
y++;
}
}
When I try to update my grid
string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar")).SelectedValue.ToString()
;
Response.write (XmlFirmalar);
It always returns 4 which is the default. I change my selection in the
dropdown but it returns 4
How can i solve it ?
<aspropDownList DataSource="<%# PopulateList() %>" OnLoad="SelectIndex" >
I assign selected index of the my dropdown in SelectIndex function.
protected void SelectIndex(object source, System.EventArgs e)
{
DropDownList DXmlFirmalar = (DropDownList)source;
DataSet ds = (DataSet)DataGrid1.DataSource;
DataTable tb=ds.Tables[0];
DataRow row = tb.Rows[DataGrid1.EditItemIndex];
////////////////////////////
///
SqlConnection baglantim=con.MyConnect ();
DataSet ds1=new DataSet ();
ds1=con.GetFirmalar(baglantim);
int y=0;
foreach (DataRow item in ds1.Tables[0].Rows )
{
if (row["XmlFirmalar"].Equals(item["Firma_ID"].ToString()))
DXmlFirmalar.SelectedIndex=y;
y++;
}
}
When I try to update my grid
string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar")).SelectedValue.ToString()
;
Response.write (XmlFirmalar);
It always returns 4 which is the default. I change my selection in the
dropdown but it returns 4
How can i solve it ?