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

Rad Grid With Multiple User Control

1 Answer 96 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mani
Top achievements
Rank 1
mani asked on 24 Feb 2009, 05:45 AM
Hi
     I implemented the projects Asp.Net with Telerik. My one of the Module include the  Different Contact Types. Each Contact Types  to have User control. When i Edit the Rad Grid in that time must be show the related contact types user control. Let me know how can i implemented the funcationality ...

Regards
G. Manikandang

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 24 Feb 2009, 07:08 AM
Hi Mani,

I suppose you are trying to use different UserControls for each row in the grid. If thats the case, you can check for the datakeyvalue or cell text of the row and then change the UserControlName for the grid. Check out the code below to understand better:
aspx:
<telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1" runat="server" OnItemCommand="RadGrid1_ItemCommand"
    <MasterTableView DataKeyNames="ProductID" DataSourceID="SqlDataSource1">  
       <Columns> 
        ... 
        <telerik:GridEditCommandColumn>         
        </telerik:GridEditCommandColumn> 
       </Columns> 
       <EditFormSettings EditFormType="WebUserControl"
            <EditColumn> 
            </EditColumn> 
       </EditFormSettings> 
    </MasterTableView> 
</telerik:RadGrid> 

cs:
 
protected void RadGrid1_ItemCommand(object source, Telerik.Web.UI.GridCommandEventArgs e)  
    {  
        if (e.CommandName == RadGrid.EditCommandName)  
        {  
            GridDataItem item = (GridDataItem)e.Item;         
            switch(item.GetDataKeyValue("ProductID").ToString())  
            {  
                case "1":  
                    RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl1.ascx";   
                    break;  
                case "2":  
                    RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl2.ascx";    
                    break;     
                 // similarly set code for other case values            
            }              
        }  

Thanks
Princy.
Tags
Grid
Asked by
mani
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or