This is a migrated thread and some comments may be shown as answers.

Programmatically Create/Retrieve RadGrid Data

4 Answers 166 Views
Grid
This is a migrated thread and some comments may be shown as answers.
s
Top achievements
Rank 1
s asked on 01 Jun 2011, 11:18 PM
I've created a RadGrid programmatically.  What I'm trying to do is save it programmatically.  I've created an asp save button to do this, and I've tried writing a save function.  My problem is that when I try to access much of the component data of the RadGrid from the save function, it is not there.  Not just the contents of the RadGrid, but the grid columns themselves are missing.  I'm not sure why that is.  Is it because I've declared them with the OnPreRender and OnDataBound methods?

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 02 Jun 2011, 10:32 AM
Hello,

 Here is a sample code that I tried from external button click to access TextBox in grid.

C#:
protected void Button1_Click(object sender, EventArgs e)
{
        foreach (GridDataItem item in RadGrid2.Items)
        {
        TextBox txtbox = (TextBox)item["txtbox"].Controls[0];
           }
 }

Check the following help documentation which explains more about this.
Programmatic creation.

Also check the help article which explains how to access cells and rows.
Accessing cells and rows.


Thanks,
Princy.
0
s
Top achievements
Rank 1
answered on 02 Jun 2011, 05:10 PM
I can see different rows, but I can't seem to see the columns when I use the debugger.  Is "txtbox" the column name?  What does "Controls[0]" do?
0
Jayesh Goyani
Top achievements
Rank 2
answered on 02 Jun 2011, 06:21 PM
Hi,
for boundcolumn ...
  <telerik:GridBoundColumn  UniqueName="ColumnUniqueName">  </telerik:GridBoundColumn>



TextBox txtbox = (TextBox)item["ColumnUniqueName"].Controls[0];

control[0] : it will get control from gridboundcolumn
telerik use textbox control for display our datafield's value of/in boundcolumn.

Thanks,
Jayesh Goyani
0
s
Top achievements
Rank 1
answered on 03 Jun 2011, 04:04 PM

My RadGrid is constructed programmatically from a DataTable, and the DataTable is constructed from DataColumns.

Tags
Grid
Asked by
s
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
s
Top achievements
Rank 1
Jayesh Goyani
Top achievements
Rank 2
Share this question
or