Dave Hollen
Top achievements
Rank 1
Dave Hollen
asked on 05 Jan 2010, 06:52 PM
Hello,
What I would like to do is to have a user control be displayed instead of a dialog when clicking the Delete button on my radGrid. I know you can make this happen when clicking the Edit button on the radgrid, but would like to do the same with the Delete button. The reason being is that the user needs to reassign child records of the parent record to another parent upon delete of that parent. The user must select the parent to reassign the child records to.
Is is possible to have a User Control appear on click of the Delete button similar to how we can have a user control appear on click of the Edit button in the RadGrid? If so, how?
Thanks,
Dave
What I would like to do is to have a user control be displayed instead of a dialog when clicking the Delete button on my radGrid. I know you can make this happen when clicking the Edit button on the radgrid, but would like to do the same with the Delete button. The reason being is that the user needs to reassign child records of the parent record to another parent upon delete of that parent. The user must select the parent to reassign the child records to.
Is is possible to have a User Control appear on click of the Delete button similar to how we can have a user control appear on click of the Edit button in the RadGrid? If so, how?
Thanks,
Dave
3 Answers, 1 is accepted
0
Princy
Top achievements
Rank 2
answered on 06 Jan 2010, 06:57 AM
Hello Dave,
Here's an example of how to display a window on clicking the delete button in the grid:
aspx:
c#:
js:
Thanks
Princy.
Here's an example of how to display a window on clicking the delete button in the grid:
aspx:
| <telerik:RadGrid ID="RadGrid1" OnItemCreated="RadGrid1_ItemCreated" OnNeedDataSource="RadGrid1_NeedDataSource1"> |
| <MasterTableView CommandItemDisplay="Top" DataKeyNames="ID"> |
| <Columns> |
| <telerik:GridTemplateColumn> |
| <ItemTemplate> |
| <asp:LinkButton ID="DeleteLink" runat="server">Delete</asp:LinkButton> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| <telerik:RadWindowManager runat="server" ID="WinManager1"> |
| <Windows> |
| <telerik:RadWindow ID="RadWindow1" runat="server"> |
| <ContentTemplate> |
| <uc2:WebUserControl2 ID="WebUserControl2_1" runat="server" /> |
| </ContentTemplate> |
| </telerik:RadWindow> |
| </Windows> |
| </telerik:RadWindowManager> |
c#:
| protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) |
| { |
| if (e.Item is GridDataItem) |
| { |
| LinkButton btnDelete = (LinkButton)e.Item.FindControl("DeleteLink"); |
| btnDelete.Attributes["onclick"] = String.Format("return ShowForm();"); |
| } |
| } |
js:
| function ShowForm(id, rowIndex) |
| { |
| var oWnd = radopen(null,"RadWindow1"); |
| return false; |
| } |
Thanks
Princy.
0
Dave Hollen
Top achievements
Rank 1
answered on 06 Jan 2010, 04:43 PM
Is there a way to get the user control to be embedded in the grid (similar to when you use a user control as the EditForm when clicking the Edit button)?
Thanks,
Dave
Thanks,
Dave
0
Princy
Top achievements
Rank 2
answered on 07 Jan 2010, 06:53 AM
Hello Dave,
If you want to use embedded UserControls then you can switch between the userControls on clicking edit and delete. Also set the CommandName of the DeleteButton to Edit. Check out the following code to understand better:
aspx:
c#:
Thanks
Princy.
If you want to use embedded UserControls then you can switch between the userControls on clicking edit and delete. Also set the CommandName of the DeleteButton to Edit. Check out the following code to understand better:
aspx:
| <telerik:RadGrid DataSourceID="SqlDataSource1" ID="RadGrid1" runat="server" OnItemCommand="RadGrid1_ItemCommand"> |
| <MasterTableView> |
| <Columns> |
| <telerik:GridTemplateColumn> |
| <ItemTemplate> |
| <asp:LinkButton ID="DeleteLink" CommandName="Edit" CommandArgument="Delete" runat="server">Delete</asp:LinkButton> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridEditCommandColumn> |
| </telerik:GridEditCommandColumn> |
| </Columns> |
| <EditFormSettings EditFormType="WebUserControl"></EditFormSettings> |
| </MasterTableView> |
| </telerik:RadGrid> |
c#:
| protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
| { |
| if (e.CommandName == "Edit") |
| { |
| if (e.CommandArgument == "Delete") |
| { |
| RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl2.ascx"; |
| } |
| else |
| { |
| RadGrid1.MasterTableView.EditFormSettings.UserControlName = "WebUserControl1.ascx"; |
| } |
| } |
| } |
Thanks
Princy.