Reputation: 25
I have a module on C# for DNN, the purpose is to display a list of customers and allow only people from certain groups to see the page and their data. this is my ascx file for the view part
<%@ Control Language="C#" Inherits="OnCoreNet.Modules.CFT_Manager.ViewCFT_Manager"
AutoEventWireup="true" CodeBehind="ViewCFT_Manager.ascx.cs" %>
<asp:GridView ID="customerGrid" runat="server" EnableModelValidation="True"
Width="100%" AllowPaging="True" AutoGenerateColumns="False"
PagerSettings-Mode="NumericFirstLast"
PagerSettings-PageButtonCount="10"
onpageindexchanging="customerGrid_PageIndexChanging"
onrowdatabound="customerGrid_RowDataBound">
<Columns>
<asp:BoundField HeaderStyle-Width="50px" ItemStyle-HorizontalAlign="Center" />
<asp:BoundField ConvertEmptyStringToNull="False" HeaderText="Cust. Name"
NullDisplayText=" " ReadOnly="True" DataField="CFT_CustomerName" />
<asp:BoundField ConvertEmptyStringToNull="False" DataField="CFT_CustomerKey"
HeaderText="Cust. Key" NullDisplayText=" " ReadOnly="True" HeaderStyle-Width="100px" />
<asp:BoundField ConvertEmptyStringToNull="False" DataField="CFT_CustomerCode"
HeaderText="Cust. Code" NullDisplayText=" " ReadOnly="True" HeaderStyle-Width="100px" />
</Columns>
</asp:GridView>
On the first cell I display 2 icons for edit and delete, with this code:
protected void customerGrid_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
CFT_ManagerInfo customerInfo = (CFT_ManagerInfo)e.Row.DataItem;
e.Row.Cells[0].Controls.Clear();
ImageButton imgEdit = new ImageButton();
imgEdit.ImageUrl = "/images/edit.gif";
imgEdit.PostBackUrl = EditUrl("CFT_ID", customerInfo.CFT_ID.ToString());
imgEdit.CommandName = "EditCustomerBtn";
e.Row.Cells[0].Controls.Add(imgEdit);
ImageButton imgDel = new ImageButton();
imgDel.ImageUrl = "/images/delete.gif";
imgEdit.PostBackUrl = EditUrl("CFT_Customer_ID", customerInfo.CFT_ID.ToString(), "DelCustomer");
imgEdit.CommandName = "DelCustomerBtn";
e.Row.Cells[0].Controls.Add(imgDel);
Response.Write("Image URL: " + imgEdit.PostBackUrl + "<br>\n");
Response.Write("Image URL: " + imgDel.PostBackUrl + "<br>\n");
//Response.Write("CFT_ID: " + customerInfo.CFT_ID.ToString() + "<br>\n");
}
}
The images are displayed, but if I click on the icon it sends me an error, these are the links that EditUrl is sending:
http://localhost/CFTTest/tabid/88/ctl/DelCustomer/mid/415/CFT_Customer_ID/11/Default.aspx
The arget page is called EditCFT_Manager.ascx, that's the defulat name VS gave it. I don't know what I'm doing wrong, I'm fairly new on DNN module development.. can you help me out please?
Upvotes: 1
Views: 1912
Reputation: 155895
Using EditUrl
to create the URL, DNN will look for a control in the module's definition with the given key, either DelCustomer
or Edit
(since you didn't specify the key). Assuming that you have a module manifest, you should be able to see where the main view control is defined, and copy it for those two keys, to point them to the user controls (see the Manifest - Module Component entry in the DNN wiki for details).
Upvotes: 1