Hi,
I want to use dropdowns in a radgrid.
When i enter into edit mode, i want to show the selected value in the dropdown .
How can i do this?
So far this is my code.
Thanks
<
telerik:GridTemplateColumn
HeaderText
=
"City"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblcity"
runat
=
"server"
Text='<%# Bind("CityID") %>'></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
asp:DropDownList
ID
=
"ddlCity"
runat
=
"server"
>
</
asp:DropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
Code Behind:
protected
void
gdv_Drivers_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
((e.Item
is
GridEditableItem && ((GridEditableItem)e.Item).IsInEditMode))
{
string
where =
null
;
// string cityid = ((DropDownList)e.Item.FindControl("ddlcity")).SelectedValue;
// string stateid = ((DropDownList)e.Item.FindControl("ddlstate")).SelectedValue;
// string zipid = ((DropDownList)e.Item.FindControl("ddlzip")).SelectedValue;
DropDownList ddlcity, ddlstate, ddlzip;
ddlcity = ((DropDownList)e.Item.FindControl(
"ddlCity"
));
ddlstate = ((DropDownList)e.Item.FindControl(
"ddlState"
));
ddlzip = ((DropDownList)e.Item.FindControl(
"ddlZip"
));
myGlobal.LoadDropDown(ddlcity,
"tbl_CityLkup"
,
"CityID"
,
"CityNm"
,
"GCRPC"
,
"CityID"
,
"CityNm"
, where);
myGlobal.LoadDropDown(ddlstate,
"tbl_StateLkup"
,
"StateID"
,
"StateNm"
,
"GCRPC"
,
"StateID"
,
"StateNm"
, where);
myGlobal.LoadDropDown(ddlzip,
"tbl_ZipLkup"
,
"ZipID"
,
"ZipCd"
,
"GCRPC"
,
"ZipID"
,
"ZipCd"
, where);
}
}