I have a dropdownlist in a GridTemplateColumn (see code attached). I have C# backend code to update the sql database when an Update is performed. All of this worked fine until I changed a couple of the edit fields to dropdowns. I can't seem to get the value of the dropdown selected item when I update. The dropdown id="StatusDD". Can anyone help?
Thanks in advance
Tom
Thanks in advance
Tom
5 Answers, 1 is accepted
0

Tom
Top achievements
Rank 1
answered on 09 May 2014, 05:38 PM
Maybe I should ask a different question here. I will be using the grid on several applications in asp.net (c#). These apps simply use sql data. When updating or inserting records, I like to use dropdownlists to simplify data entry and keep data consistent. So which radgrid objects ( like GridBound, GridEdit, Grid Template, etc)should I use for this type of app. I generally use back-end C# code to perform the Sql updates and inserts. This is where I'm having an issue when trying to retrieve the data from the dropdown.
0

Princy
Top achievements
Rank 2
answered on 12 May 2014, 08:45 AM
Hi Tom,
In order to have a dropdownlist you can either use a GridTemplateColumn, with EditItemTemplate or GridDropDownColumn which will have a dropdown in edit mode. Below is a sample code that shows how to access the both:
ASPX:
C#:
Thanks,
Princy
In order to have a dropdownlist you can either use a GridTemplateColumn, with EditItemTemplate or GridDropDownColumn which will have a dropdown in edit mode. Below is a sample code that shows how to access the both:
ASPX:
<
telerik:GridTemplateColumn
>
<
EditItemTemplate
>
<
telerik:RadDropDownList
ID
=
"RadDropDownListCity"
runat
=
"server"
DataSourceID
=
"SqlDataSource2"
DataTextField
=
"ShipCity"
DataValueField
=
"ShipCity"
>
</
telerik:RadDropDownList
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridDropDownColumn
UniqueName
=
"ShipCity"
ListTextField
=
"ShipCity"
ListValueField
=
"ShipCity"
DataSourceID
=
"SqlDataSource2"
HeaderText
=
"ShipCity"
DataField
=
"ShipCity"
DropDownControlType
=
"DropDownList"
>
</
telerik:GridDropDownColumn
>
C#:
protected
void
RadGrid1_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
if
(e.Item
is
GridEditableItem)
{
GridEditableItem editItem = (GridEditableItem)e.Item;
//Accessing a Template column
RadDropDownList raddrplstShipCity = (RadDropDownList)editItem.FindControl(
"RadDropDownListCity"
);
string
selectedText=raddrplstShipCity.SelectedItem.Text;
//Accessing a DropDownColumn
DropDownList raddpcolShipCity = (DropDownList)editItem[
"ShipCity"
].Controls[0];
string
selectedColText = raddpcolShipCity.SelectedItem.Text;
}
}
Thanks,
Princy
0

Tom
Top achievements
Rank 1
answered on 12 May 2014, 01:27 PM
Princy, Your the best. Sorry for being a beginner. Do you have a class for advanced usage of the RedGrid. I'll be using many of these in the future.
Thanks again
Tom
Thanks again
Tom
0

Princy
Top achievements
Rank 2
answered on 13 May 2014, 04:12 AM
Hi Tom,
I'm not clear about your requirement. If you want to have more details about RadGrid and its functionalities, Telerik provide well defined documentations and Online demos which will help you to understand the control better. Take a tour through the following help links:
Telerik UI for ASP.NET AJAX Documentation
RadGrid - Telerik's ASP.NET Grid Demo
Thanks,
Princy
I'm not clear about your requirement. If you want to have more details about RadGrid and its functionalities, Telerik provide well defined documentations and Online demos which will help you to understand the control better. Take a tour through the following help links:
Telerik UI for ASP.NET AJAX Documentation
RadGrid - Telerik's ASP.NET Grid Demo
Thanks,
Princy
0

Tom
Top achievements
Rank 1
answered on 13 May 2014, 01:08 PM
I've got it all fixed now.
Thanks Princy
Tom
Thanks Princy
Tom