1

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?

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
Soqui
  • 25
  • 5

1 Answers1

1

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).

bdukes
  • 152,002
  • 23
  • 148
  • 175
  • Hi, I was able to jump to the Edit form of my module, but can't get any querystring from the view module, I fixed the way I used the EditURL, the parameters are Key (I understand is the param name for quesry string), value (the vlue of the param) and the Controlkey. In my manfest file there is a entry called key with value Edit, I used this on the ControlKey param but I still get no values. – Soqui May 25 '12 at 17:34
  • Complementing my question above.. I noticed that the typical if(!IsPostBack) condition on the edit page is not met.. is this ok or I'm maaking something wrong?? – Soqui May 25 '12 at 17:56