4 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 26 Nov 2013, 05:11 AM
Hi Edd,
I guess you are selecting the row using CheckBox inside the GridTemplate column and that a TextBox and Button is outside the RadGrid. I suppose, on the selected row you want to update the value of column with TextBox value. Please try the following code snippet.
ASPX:
C#:
Thanks,
Princy
I guess you are selecting the row using CheckBox inside the GridTemplate column and that a TextBox and Button is outside the RadGrid. I suppose, on the selected row you want to update the value of column with TextBox value. Please try the following code snippet.
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" AllowMultiRowSelection="true"> <MasterTableView > <Columns> <telerik:GridBoundColumn DataField="ClassNo" HeaderText="ClassNo" UniqueName="ClassNo" /> <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn"> <ItemTemplate> <asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" /> </ItemTemplate> </telerik:GridTemplateColumn> </Columns> </MasterTableView> </telerik:RadGrid><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="UpdateBtn" runat="server" Text="Update" OnClick="UpdateBtn_Click" />C#:
protected void ToggleRowSelection(object sender, EventArgs e) { //Select the Checked Row ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked; }protected void UpdateBtn_Click(object sender, EventArgs e) { var key = string.Empty; string text = TextBox1.Text; foreach (GridDataItem item in RadGrid1.SelectedItems) { key = item.ItemIndex.ToString(); // Index of the Selected row item["ClassNo"].Text = text; } }Thanks,
Princy
0
Edd
Top achievements
Rank 1
answered on 26 Nov 2013, 05:25 PM
please it updates it just on the client side.
How can i update it on the server side
How can i update it on the server side
0
Princy
Top achievements
Rank 2
answered on 27 Nov 2013, 04:37 AM
Hi Edd,
I guess you want to make the changes into DB. Please try the following code snippet in the button click.
C#:
Thanks,
Princy
I guess you want to make the changes into DB. Please try the following code snippet in the button click.
C#:
protected void UpdateBtn_Click(object sender, EventArgs e) { var key = string.Empty; string text= TextBox1.Text; foreach (GridDataItem item in RadGrid1.SelectedItems) { key = item.GetDataKeyValue("ID").ToString(); // Your code to Update to DB set ClassNo=text, where id=key } RadGrid1.Rebind(); }Thanks,
Princy
0
Edd
Top achievements
Rank 1
answered on 27 Nov 2013, 06:31 PM
Thank you it worked perfectly for me