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

[Solved] Bind grid at runtime

3 Answers 234 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prathibarani
Top achievements
Rank 1
Prathibarani asked on 11 Mar 2013, 07:46 PM

Hi,

 

We are new to telerik controls.

We are using visual studio 2012, .net framwork 4.5 C# for our asp.net web applications. Currently we are using infragistics. Management decided to try another suite. So, Recently, downloaded Telerik controls to test. We use grid extensively in all our applications.

This is what I need:

 

  1. Add RadGrid at designtime and bind to grid. We know exactly what fields from database. An object is used to bind to grid.
  2. Populate at runtime. (I need to know which events fire and when and order of events). Right now we are doing this in page_load event and not post back.
  3. When data is added like (datbind happens), I need to change the URL of hyperlinks (that are added at design time using template columns) of that row based on values in that row’s other fields. Infragistics has ‘RowInitialize’ event. So, we do lot of work in that event.
  4. We hide some columns and hide and show some other columns based on certain criteria.

I appreciate your response
Katta

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 12 Mar 2013, 04:55 AM
Hi,

When creating RadGrid on Page_Load event, the columns or detail tables should be added to the corresponding collection first and then values for the properties of this instance should be set. When generating a grid in the Page_Init event handler, grid columns should be added to the Columns collection of the MasterTableView after their attributes are set. In order to show hyperlinks, you must create the templates dynamically in the code-behind and assign them to the ItemTemplate properties of the column. In order to hide the column try the following code.
C#:
if(condition)
{
    RadGrid1.MasterTableView.GetColumn("UniqueName").Display=false;
 }
Thanks,
Shinu
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 12 Mar 2013, 05:02 AM
Hello,

This is what I need:

 

  1. Add RadGrid at designtime and bind to grid. We know exactly what fields from database. An object is used to bind to grid.Please check dataBinding section in this link.
  2. Populate at runtime. (I need to know which events fire and when and order of events). Right now we are doing this in page_load event and not post back. for binding the datasource to radgrid please use advance data binding method,
Telerik RadGrid lifecycle
Event sequence
RadGrid Events
  1. When data is added like (datbind hap pens), I need to change the URL of hyperlinks (that are added at design time using template columns) of that row based on values in that row’s other fields. Infragistics has ‘RowInitialize’ event. So, we do lot of work in that event By using rowdatabound/ItemCreated event you can achieve this thing. http://www.telerik.com/community/forums/aspnet-ajax/menu/binding-navigate-url-within-a-radgrid-itemtemplate.aspx
  2. We hide some columns and hide and show some other columns based on certain criteria.
     For that you can use either Grid_Prereder event or Page_Prerender event.
    http://www.telerik.com/community/forums/aspnet-ajax/grid/radgrid-removing-column-on-runtime.aspx#696342
http://www.telerik.com/help/aspnet-ajax/grid-using-columns.html

Thanks,
Jayesh Goyani
0
Prathibarani
Top achievements
Rank 1
answered on 01 Apr 2013, 03:29 PM
Thanks both of you.

Prathiba
Tags
Grid
Asked by
Prathibarani
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jayesh Goyani
Top achievements
Rank 2
Prathibarani
Top achievements
Rank 1
Share this question
or