Hi,
I have a RadComboBox which will contain all the Column name of RadGrid. Next To the RadComboBox I have a RadTextBox. when i enter a value in textbox and i choose any item in the comboBox, then that particular column in RadGrid (all the rows) should be Updated with the Value entered in the TextBox. Is it is possible. How ? any Sample code is available.
I have a RadComboBox which will contain all the Column name of RadGrid. Next To the RadComboBox I have a RadTextBox. when i enter a value in textbox and i choose any item in the comboBox, then that particular column in RadGrid (all the rows) should be Updated with the Value entered in the TextBox. Is it is possible. How ? any Sample code is available.
6 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 09 Feb 2011, 12:42 PM
Hello Venkatesh,
The following code snippet shows how to achieve this.
ASPX:
C#:
Thanks,
Princy.
The following code snippet shows how to achieve this.
ASPX:
<telerik:RadComboBox runat="server" ID="RadComboBox1" AutoPostBack="True" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"> <Items> <telerik:RadComboBoxItem Text="EmployeeID" Value="EmployeeID" /> <telerik:RadComboBoxItem Text="FirstName" Value="FirstName" /> <telerik:RadComboBoxItem Text="user_role" Value="user_role" /> </Items></telerik:RadComboBox><asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br /><telerik:RadGrid ID="RadGrid1" AutoGenerateColumns="false" runat="server" DataSourceID="SqlDataSource1"> <MasterTableView> <Columns> <telerik:GridBoundColumn DataField="EmployeeID" HeaderText="EmployeeID" UniqueName="EmployeeID"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="FirstName" HeaderText="FirstName" UniqueName="FirstName"> </telerik:GridBoundColumn> <telerik:GridBoundColumn DataField="user_role" HeaderText="user_role" UniqueName="user_role"> </telerik:GridBoundColumn> </Columns> </MasterTableView></telerik:RadGrid>C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { RadComboBox combo = (RadComboBox)sender; foreach (GridColumn col in RadGrid1.Columns) { if (col.UniqueName == combo.SelectedValue) { foreach (GridDataItem item in RadGrid1.Items) { item[col.UniqueName].Text = TextBox1.Text; } } } }Thanks,
Princy.
0
Venkatesh
Top achievements
Rank 1
answered on 09 Feb 2011, 02:58 PM
Hi Princy,
Thank you For your Solution.I have One Problem. I am importing the Data form Excel to RadGrid.I don't have any GridBoundColumn in the RadGrid.
Thank you For your Solution.I have One Problem. I am importing the Data form Excel to RadGrid.I don't have any GridBoundColumn in the RadGrid.
0
Accepted
Princy
Top achievements
Rank 2
answered on 10 Feb 2011, 06:21 AM
Hello Venkatesh,
If that the case try the following code snippet .
C#:
Hope this helps,
Princy.
If that the case try the following code snippet .
C#:
protected void RadComboBox1_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e) { RadComboBox combo = (RadComboBox)sender; foreach (GridColumn col in RadGrid1.MasterTableView.AutoGeneratedColumns) { if (col.UniqueName == combo.SelectedValue) { foreach (GridDataItem item in RadGrid1.Items) { item[col.UniqueName].Text = TextBox1.Text; } } } }Hope this helps,
Princy.
0
Venkatesh
Top achievements
Rank 1
answered on 10 Feb 2011, 06:26 AM
foreach (GridColumn col in RadGrid1.MasterTableView.AutoGeneratedColumns)this statement is not a valid one. Foreach can't have thi
sAutoGeneratedColumns because this is bool type0
Jayesh Goyani
Top achievements
Rank 2
answered on 10 Feb 2011, 07:18 AM
Hi, Venkatesh
AutoGenerateColumns has a bool type.
but in princy's code
so it worked successfully.
regards,
Jayesh Goyani
AutoGenerateColumns has a bool type.
but in princy's code
AutoGeneratedColumns. (generate/generated)so it worked successfully.
regards,
Jayesh Goyani
0
Venkatesh
Top achievements
Rank 1
answered on 10 Feb 2011, 07:37 AM
Sorry i was in a hurry that why i didn't notice the property clearly. any how thanks Princy for your solution, it worked. And also thanks to Jayesh