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

TomTOM75

4 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 17 Sep 2008, 11:32 AM
Hello

Not sure if this is possible, but I would like to know if this is possible and if it is can I ge an example...

I have a user control that displays data that I read from the database. I want to use the Grid with custom paging to render the usercontrol within the cell of the grid. So basically I would have 1 column (cell) in the grid and infinite rows... Is this possible to render a usercontrol into a cell? Which method would I have to implement to assign the row values to my user control? Can I implement this along with Filtering and paging?

If I could get any example of this I would sincerely appreciate it.. It can be a real small example, but covering the usercontrol, filtering and custompaging...

Thank You,
Thomas Radomski

4 Answers, 1 is accepted

Sort by
0
Dimo
Telerik team
answered on 17 Sep 2008, 12:02 PM
Hi Thomas,

You can use a template column. Here are some examples and help articles, related to your scenario:

RadGrid Column Types Demo
RadGrid Column Types Help Article

RadGrid Custom Paging Demo
RadGrid Custom Paging Help Article

RadGrid - Template Column Filtering Demo
RadGrid - Template Column Filtering Help Article


By the way, it is not required to use custom paging in this scenario, this is up to you.


Sincerely yours,
Dimo
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Princy
Top achievements
Rank 2
answered on 17 Sep 2008, 12:16 PM
Hi Thomas,

One other suggestion will be to create the usercontrol in the code behind and adding it to a particular cell as shown below.

CS:
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
 
        if (e.Item is GridDataItem) 
        { 
            UserControl usercontrol = UserControl(); 
            usercontrol.ID = "UserControl1"
            Label lbl = new Label(); 
            lbl.ID = "Label1"; ; 
            lbl.Text = "New Text"
            usercontrol.Controls.Add(lbl); 
 
            GridDataItem item = (GridDataItem)e.Item; 
            if (item["ProductName"].Text == "MyText") 
            { 
                item["ProductName"].Controls.Add(usercontrol); 
            } 
        } 
    } 


Princy
0
Thomas
Top achievements
Rank 1
answered on 17 Sep 2008, 12:43 PM
thanks!
0
Thomas
Top achievements
Rank 1
answered on 17 Sep 2008, 04:16 PM

Princy, I created a user control with some labels and buttons.. I tried to show this in my IndexID column, but when it runs I see just a blank column for all the rows.. Am I doing something wront..

protected
void radgrdCRE_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)

{

if (e.Item is GridDataItem)

{

GridDataItem item = (GridDataItem)e.Item;

if (item != null)

{

WebUserControl1 usercontrol = new WebUserControl1();

usercontrol.ID =

"UserControl1";

// usercontrol.Label1.Text = "Text1";// item["IndexID"].Text;

// usercontrol.Label2.Text = "text2";// item["IndexText"].Text;

item[

"IndexID"].Controls.Add(usercontrol);

}

}

}

Tags
Grid
Asked by
Thomas
Top achievements
Rank 1
Answers by
Dimo
Telerik team
Princy
Top achievements
Rank 2
Thomas
Top achievements
Rank 1
Share this question
or