hi
i wanted to edit the values inside the grid so that i wanted to get all the entered values and update using updatecommand.
from text box i am able to get the values in updatecommand but in case of combobox i am not able to get the selectedvalue of the combobox in code behind of updatecommaond of gridview.
can any one plz post me the code to update data using combobox and checkboxes if possible..
Thanks
Santosh
i wanted to edit the values inside the grid so that i wanted to get all the entered values and update using updatecommand.
from text box i am able to get the values in updatecommand but in case of combobox i am not able to get the selectedvalue of the combobox in code behind of updatecommaond of gridview.
can any one plz post me the code to update data using combobox and checkboxes if possible..
Thanks
Santosh
3 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 18 Feb 2013, 11:54 AM
Hi,
Try the following code to achieve your scenario.
C#:
Thanks,
Shinu
Try the following code to achieve your scenario.
C#:
protected
void
RadGrid1_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem item = (GridEditableItem)e.Item;
RadComboBox combo = (RadComboBox)item.FindControl(
"RadComboBox1"
);
string
value = combo.SelectedValue.ToString();
}
Thanks,
Shinu
0

San
Top achievements
Rank 1
answered on 18 Feb 2013, 12:44 PM
Thanks for ur reply..
same code i have tried already but it's not working ,selected value is returning null..
i guess some other problem is there in my code..
plz check the below code
<telerik:GridTemplateColumn HeaderText="ProposalType"
SortExpression="ProposalType">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "ProposalCodeId")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="ProposalType" runat="server"
DataSourceID="PropDataSource" DataTextField="ProposalCode"
DataValueField="InternalID" EnableLoadOnDemand="True"
Text='<%# Bind("ProposalCodeId")%>' Width="60px">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<asp:SqlDataSource ID="PropDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:Payment %>"
SelectCommand="Select InternalID,ProposalCode,ProposalName from tbl_PymtProposalType"></asp:SqlDataSource>
if you could give me any example using combobox in grid would be better to understing..
Thanks in advance..
San
same code i have tried already but it's not working ,selected value is returning null..
i guess some other problem is there in my code..
plz check the below code
<telerik:GridTemplateColumn HeaderText="ProposalType"
SortExpression="ProposalType">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "ProposalCodeId")%>
</ItemTemplate>
<EditItemTemplate>
<telerik:RadComboBox ID="ProposalType" runat="server"
DataSourceID="PropDataSource" DataTextField="ProposalCode"
DataValueField="InternalID" EnableLoadOnDemand="True"
Text='<%# Bind("ProposalCodeId")%>' Width="60px">
</telerik:RadComboBox>
</EditItemTemplate>
</telerik:GridTemplateColumn>
<asp:SqlDataSource ID="PropDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:Payment %>"
SelectCommand="Select InternalID,ProposalCode,ProposalName from tbl_PymtProposalType"></asp:SqlDataSource>
if you could give me any example using combobox in grid would be better to understing..
Thanks in advance..
San
0

Shinu
Top achievements
Rank 2
answered on 19 Feb 2013, 04:41 AM
Hi,
Here is the full code that I tried which worked as expected.
aspx:
C#:
Also check this demo for more.
Thanks,
Shinu
Here is the full code that I tried which worked as expected.
aspx:
<
telerik:RadGrid
ID
=
"RadGrid1"
AutoGenerateEditColumn
=
"true"
runat
=
"server"
DataSourceID
=
"SqlDataSource2"
AutoGenerateColumns
=
"false"
OnUpdateCommand
=
"RadGrid1_UpdateCommand"
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridTemplateColumn
DataField
=
"ShippedDate"
>
<
EditItemTemplate
>
<
telerik:RadComboBox
ID
=
"ProposalType"
runat
=
"server"
DataSourceID
=
"SqlDataSource1"
DataTextField
=
"EmployeeID"
DataValueField
=
"LastName"
Text='<%# Bind("OrderID")%>' Width="60px"></
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="select top 20 * from [Orders]"></
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="select EmployeeID,LastName from [Employees]"></
asp:SqlDataSource
>
protected
void
RadGrid1_UpdateCommand(
object
sender, GridCommandEventArgs e)
{
GridEditableItem item = (GridEditableItem)e.Item;
RadComboBox combo = (RadComboBox)item.FindControl(
"ProposalType"
);
string
value = combo.SelectedValue.ToString();
}
Thanks,
Shinu