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

how to populate columns at design time ?

1 Answer 72 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ragupathi
Top achievements
Rank 1
Ragupathi asked on 09 Sep 2008, 05:43 AM
Hi,
  My application has capabitily to design the forms at runtime and ll host to some server. that case I have to give the preview functionality for the radgridview to User.

So when user drag and drop the radgridview from the toolbox itself i need to display the popuation of the required columns with some test data.

I am capturing the event of the drag and drop through Idesignerhost and in that , I had put the following code. The code is executing fine but the databinding is not reflected in the gridview. but if we give datasoure in design time we are able to see the columns with all data. I need the same kind of functionality through code and columns will be decided through code.

DataTable myDataTable = new DataTable();

myDataTable.Columns.Add(

"ControlID", typeof(String));

myDataTable.Columns.Add(

"UpdateField", typeof(String));

myDataTable.Columns.Add(

"DisplayField", typeof(String));

DataRow row;

row = myDataTable.NewRow();

row[

"ControlID"] = "Data";

row[

"UpdateField"] = "Data";

row[

"DisplayField"] = "Data";

 

myDataTable.Rows.Add(row);

draggedGrid.DataSource = myDataTable;

draggedGrid.DataBind();

Pleae let me know if my question not make sense..

Many thanks in advance.
Raghu



1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 11 Sep 2008, 08:10 AM
Hi Ragupathi,

By default AutoGenerateColumns of the GridViewTemplate is set to true. When you set a DataSource the columns will be generated automatically, but data will be shown only in run time.

If you use RadGridView in design time, the UI supports only columns generated and serialized from the DataSource.

I hope this was helpful. If you have additional questions, please contact us.
 

Sincerely yours,
Julian Benkov
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Ragupathi
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or