DROPDOWN SELECTED PROPERTY PROBLEM

G

Guest

I have a Datagrid and it has a dropdown.

<asp:DropDownList 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 ?
 
D

Duggi

string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar")).SelectedValue.ToString(­)

;


I think you should pharse the query with selectedIndex also.... you are
not selecting an index it seems...

atleast
comboBox1.SelectedIndex
is working for me in WinForms

Thanks
-Srinivas
 
G

Guest

<select name="DataGrid1:_ctl3:DXmlFirmalar"
id="DataGrid1__ctl3_DXmlFirmalar">
<option value="1">Ereyon</option>
<option value="2">Kangurum</option>
<option value="3">SiberStore</option>
<option selected="selected" value="4">WebdenAl</option>
<option value="5">Weblebi</option>

</select>


string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar")).SelectedIndex.ToString()
;

returns 3

string XmlFirmalar
=((DropDownList)e.Item.FindControl("DXmlFirmalar")).SelectedValue.ToString()
;

returns 4

it doesnt care about my selection in html page.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top