1

我有一个用于 DNN 的 C# 模块,目的是显示客户列表,并只允许来自某些组的人查看页面及其数据。这是我的视图部分的 ascx 文件

<%@ 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>

在第一个单元格中,我使用以下代码显示 2 个用于编辑和删除的图标:

        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");
        }
    }

图像已显示,但如果我单击它会向我发送一个错误的图标,这些是 EditUrl 正在发送的链接:

http://localhost/CFTTest/tabid/88/ctl/DelCustomer/mid/415/CFT_Customer_ID/11/Default.aspx

arget 页面称为 EditCFT_Manager.ascx,这是 VS 给它的默认名称。我不知道我做错了什么,我对 DNN 模块开发还很陌生..你能帮帮我吗?

4

1 回答 1

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

于 2012-05-25T04:55:48.393 回答