受window.open影响的GridView

时间:2013-09-27 08:51:16

标签: c# asp.net gridview

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

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

任何可能导致这种情况的想法?单步执行代码时,在btnEnvComment_Click

之后没有执行其他行

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

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

0 个答案:

没有答案