0

我有一个 gridView 可以很好地工作,直到我通过单击按钮打开一个新窗口。当新窗口打开时,“lblTotalPrice”列之一中的值将被删除。'lblTotalPrice' 是一个模板字段,在 MealList_RowDataBound(数量 * 价格)中计算。但是,当新窗口打开时,列的页脚不受影响(也在 MealList_RowDataBound 中获取其值)。

当新窗口打开时,数据绑定列的字体大小也会改变。

关于可能导致这种情况的任何想法?单步执行代码时,在 btnEnvComment_Click 之后没有执行其他行

当 gridView 再次数据绑定时,一切恢复正常。

网格视图:

        <rwg:BulkEditGridView ID="MealList" runat="server" AutoGenerateColumns="False" ShowFooter="True" GridLines="Vertical" CellPadding="4"
            BackColor="White"  DataKeyNames="ItemId,ProductId" SaveButtonID="SaveButton"
            DataSourceID="SqlMealItems" style="float:left"
            OnRowDataBound="MealList_RowDataBound"  OnRowCreated="MealList_RowCreated" CssClass="gridView">
            <AlternatingRowStyle CssClass="MealListItemAlt" BackColor="#a6dbed" />
            <Columns>
                <asp:BoundField DataField="ProductId" HeaderText="Prod #" HeaderStyle-Wrap="false" ReadOnly="True" >
                    <HeaderStyle Wrap="False" Width="60px"></HeaderStyle>
                    <ItemStyle HorizontalAlign="Right" />
                </asp:BoundField>
                <asp:BoundField DataField="ProductName" HeaderText="Namn" ReadOnly="True" ItemStyle-Wrap="False" >
                    <ItemStyle Width="150px" />
                </asp:BoundField>
                <asp:BoundField DataField="Quantity" HeaderText="Antal"  ControlStyle-CssClass="numeric" >
                    <ControlStyle CssClass="numeric" Width="30px"></ControlStyle>
                </asp:BoundField>
                <asp:TemplateField HeaderText="Enhet">
                    <ItemTemplate>
                        <asp:DropDownList ID="DropDownUnit" OnSelectedIndexChanged="DropDownUnit_SelectedIndexChanged"
                            AutoPostBack="False" runat="server" DataTextField="Unit"  DataValueField="Unit">
                        </asp:DropDownList>
                    </ItemTemplate>
                    <ControlStyle Width="70px" />
               </asp:TemplateField>
               <asp:BoundField  HeaderText="á pris" ReadOnly="True"  ControlStyle-CssClass="rightAlign"  ItemStyle-Wrap="False">
                    <ControlStyle CssClass="numeric" ></ControlStyle>
                    <ItemStyle HorizontalAlign="Right" Width="80px" />
               </asp:BoundField>
               <asp:TemplateField HeaderText="Totalt"  ItemStyle-Wrap="False">
                    <ItemTemplate>
                        <asp:label ID="lblTotalPrice" runat = server></asp:label>               
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Right" Width="80px" />
                    <FooterTemplate>
                        <asp:Label ID="lblTotalPricePerMeal" runat="server"></asp:Label>
                    </FooterTemplate>
                    <FooterStyle HorizontalAlign="Right" Font-Bold="true" Font-Overline="True" Wrap="False" />
                </asp:TemplateField>
                <asp:BoundField DataField="Unit" HeaderText="h"  ReadOnly="True" />
                 <asp:TemplateField>
                    <ItemTemplate>
                        <asp:image runat="server" ID="imgBlob" Width="24"></asp:image>
                    </ItemTemplate>
                </asp:TemplateField> 
               <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Label runat="server" ID="lblError"></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField> 
           </Columns>
           <FooterStyle CssClass="MealListFooter" />
           <HeaderStyle CssClass="MealListHead" />
        </rwg:BulkEditGridView>

打开新窗口的按钮代码:

    protected void btnEnvComment_Click(object sender, EventArgs e)
    {

        int offsetPos = 125;  // set placement of new window
        String URL = "EnvComment.aspx?MealID=" + Session["MealId"];
        String responsCommand = "window.open('" + URL + "','_blank','height=400,width=300,top=" + ",left=" + offsetPos.ToString() + offsetPos.ToString() + ",titlebar=1')";
        Response.Write("<script>");
        Response.Write(responsCommand);
        Response.Write("</script>");
    }
4

0 回答 0