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

[Solved] Populate GridView without binding

5 Answers 158 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Richard Harrigan
Top achievements
Rank 1
Richard Harrigan asked on 29 Nov 2010, 08:16 PM
Hello,

I am have created a GridView and its columns....see below.  What I need to know is how to populate each row with data.  I do not have a class to bind to the GridView, I have a bound string variable for each column.  I am dealing with a data table that has three columns, a table id, column id and column value.  I also have metadata that describe the table and columns representing a traditional datarow.  I am looking to build a generic process to display tables in a gridview.  How do I add data to the GridView in this scenario?  Can I add data to the GridView without binding?

Thanks
Rich


String column1 = String.Empty;
String column2 = String.Empty;
String column3 = String.Empty;

RadGridView radGridView1 = new RadGridView();
radGridView1.CanUserInsertRows = true;
Pane5.Content = radGridView1;

GridViewDataColumn column = new GridViewDataColumn();
column.DataMemberBinding = new Binding("column1");
column.DataMemberBinding.Mode = BindingMode.TwoWay;
column.Header = "First Name";
column.UniqueName = "MyColumn1";
radGridView1.AutoGenerateColumns = false;
radGridView1.Columns.Add(column);

column = new GridViewDataColumn();
column.DataMemberBinding = new Binding("column2");
column.DataMemberBinding.Mode = BindingMode.TwoWay;
column.Header = "Last Name";
column.UniqueName = "MyColumn2";
radGridView1.AutoGenerateColumns = false;
radGridView1.Columns.Add(column);

column = new GridViewDataColumn();
column.DataMemberBinding = new Binding("column3");
column.DataMemberBinding.Mode = BindingMode.TwoWay;
column.Header = "Age";
column.UniqueName = "MyColumn3";
radGridView1.AutoGenerateColumns = false;
radGridView1.Columns.Add(column);


***** THE FOLLOWING DOES NOT WORK! ******

radGridView1.Items.AddNew();
                
column1 = "Richard";
column2 = "Harrigan";
column3 = "72";

radGridView1.Items.CommitNew();
                                

5 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 30 Nov 2010, 08:00 AM
Hello,

You can check our lightweight DataTable if you dynamic binding in Silverlight . 

Best wishes,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Richard Harrigan
Top achievements
Rank 1
answered on 30 Nov 2010, 07:08 PM
This is perfect, better than I hoped for.
0
Richard Harrigan
Top achievements
Rank 1
answered on 01 Dec 2010, 07:27 PM
Is is possible to two-way bind the DataTable and GridView.  If yes could you please provide programmatic sample code.  What I want to do is send CRUDs to the web service for processing. The web service needs to parse the row data into column data for database processing.  In the database a column is represented as a row.  Conversly when reading data from the database the Silverlight client will transform the column(s) data to a DataRow(s).

Thank you
Rich
0
Vlad
Telerik team
answered on 07 Dec 2010, 07:50 AM
Hi,

 You can read all changes from the grid Items collection - in case of the DataTable you will need to use reflection to get item properties. 

Kind regards,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
Richard Harrigan
Top achievements
Rank 1
answered on 08 Dec 2010, 05:28 PM
Hi,

Could you please provide an brief code example that finds all rows in the grid Items collection that were changed, added or deleted. Also, could you provide a link to the latest version of the dynamic datatable.

Thanks
Rich
Tags
GridView
Asked by
Richard Harrigan
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Richard Harrigan
Top achievements
Rank 1
Share this question
or