how can get selectedindex in dropdown list
how can get selectedindex in dropdown list when i use dropdownlist in html code and this is into the datalist this means i havenot use findcontrol in code behine beacuse this object not initialize
<asp:DropDownList ID="Dropdownlist1" Runat="server" DataSource='<%#FillGroup()%>' DataTextField="cat_name" DataValueField="Cat_id" >
public System.Data.DataSet FillGroup()//--new for forum App
{
System.Data.DataSet DS = new System.Data.DataSet();
sqlCmd.CommandText =" SELECT Cat_id,cat_name FROM Category where c_statuse=1 and C_public=0 ";
DS.Clear();
sqlAdp.Fill(DS);
System.Data.DataRow dr = DS.Tables[0].NewRow();
dr["Cat_id"] = "-1";
dr["cat_name"] = "ÃäÃÃÃà Ãà áÃÃÃ...";
DS.Tables[0].Rows.InsertAt(dr, 0);
return DS;
}
public string FillDropDown(object ,System.EventArgs e )
{
DataListItem anItem in datalist (is this correct
DropDownList dropdown =((DropDownList)anItem.FindControl("Dropdownlist1" ));
dropdown.SelectedItem.Value=(string)Session["result1"].ToString();;
return dropdown.SelectedItem.Value;
}
thank's for your help
|