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

[Solved] Calling UserControl on click of GridButtonColumn ButtonType

2 Answers 177 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Awadh .
Top achievements
Rank 1
Awadh . asked on 11 Nov 2009, 06:22 AM
<rad:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="../Images/editItem.gif">
                                        <HeaderStyle Font-Bold="True" Wrap="False" />
                                        <ItemStyle Wrap="true" />
                                    </rad:GridEditCommandColumn> 


<EditFormSettings UserControlName="../UserControls/EndCustomerOrderEntry.ascx" EditFormType="WebUserControl">
                                    <EditColumn UniqueName="EditCommandColumn" >
                                    </EditColumn>
                                </EditFormSettings>


Like in above code block, a user control being called for editing the rows in grid.
I need to call a similar user control for another action called RECREATE with edit option which has the grid button columns as below:





<rad:GridButtonColumn ButtonType="ImageButton" ImageUrl="../Images/Recreate.GIF" UniqueName="RecreateColumn"
                                         CommandName="Recreate">
                                        <HeaderStyle Font-Bold="True" Wrap="False"/>
                                        <ItemStyle Wrap="true" />
                                    </rad:GridButtonColumn> 


Thanks,
Awadh



2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 11 Nov 2009, 08:24 AM
Hello Awadh,

You can switch between the usercontrols  as shown below:
aspx:
<rad:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="../Images/editItem.gif">  
    <HeaderStyle Font-Bold="True" Wrap="False" />  
    <ItemStyle Wrap="true" />  
</rad:GridEditCommandColumn>  
   
<rad:GridButtonColumn ButtonType="ImageButton" ImageUrl="../Images/Recreate.GIF" UniqueName="RecreateColumn" CommandName="Edit" CommandArgument="Recreate">  
    <HeaderStyle Font-Bold="True" Wrap="False"/>  
    <ItemStyle Wrap="true" />  
</rad:GridButtonColumn>    
  
  
<EditFormSettings EditFormType="WebUserControl">  
  <EditColumn UniqueName="EditCommandColumn" >  
  </EditColumn>  
</EditFormSettings>  

c#:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Edit"
        { 
            if (e.CommandArgument == "Recreate"
            {                               
                RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl2.ascx"
            } 
            else 
            {                 
                RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl.ascx"
            } 
        } 
    } 

Thanks
Princy.
0
Awadh .
Top achievements
Rank 1
answered on 11 Nov 2009, 09:40 AM
Hi Princy,


Thanks for ur quick and prompt response because of which i was able to solve this issue.

Now I need to find the update event for other recreate user control(on click of OK button) similar to update user control(as on click of UPDATE button) in the grid from the code behind. Concerned image file illustrating this has been attached with this post.

 if (e.CommandName == RadGrid.UpdateCommandName)
            {
                UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);
                RadTextBox txtOrderValue = userControl.FindControl("txtOrderValue") as RadTextBox;


These user controls are loading in grid as suggested by your way.



Thanks,
Awadh


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