0

ページの読み込み時に表示されないグリッドビューがあります。グリッドビューは、更新パネル内にあるいくつかの asp:Panels 内にあります。コードをステップ実行したので、グリッドビューにデータ行があることがわかりました。グリッドビューをパネルの外に移動してパネルを更新すると、データが表示されます。パネルの下、パネルの内側、および更新パネルにあるときに機能しない理由を誰かが知っていますか?

    <%@ Page Language="VB" AutoEventWireup="false" EnableEventValidation="false" MasterPageFile="~/CTPublic.master" CodeFile="Tank.aspx.vb" Inherits="CargoTank_Internal_Tank" %>

<div style="padding-top:9px; width:100%; min-width:800px; " >
    <asp:UpdatePanel ID="udpTank" runat="server" >
    <ContentTemplate>
                <ajaxToolkit:RoundedCornersExtender runat="server" BorderColor="#3260a0"   Corners="All" Radius="5" Color="#98B9C9"  TargetControlID="pnlTank" ID="ajRCEpnlTank" ></ajaxToolkit:RoundedCornersExtender>

         <asp:Panel runat="server" BackColor="#ecece7"  Width="95%"  ID="pnlTank" >

             <div >
            <div style="float:left; width:70%; background-color:#98B9C9; height:19px;">Tanks</div>
            <div style="float:right; width:30%; height:19px;background-color:#98B9C9; text-align:right">
                <asp:Button ID="btnAddNewTank" style="background:transparent; border:0px;" runat="server" Font-Underline="true"   size="1" Font-Bold=true text="Add New" /> 

             </div> 
            <div style="padding-top:19px;"></div>
            </div>   
            <div style="width:100%;">
                <table width="100%">
                    <tr>
                        <td colspan="6" class="tdheaderbar">Search Tanks
                        </td>
                    </tr>
                    <tr>
                        <td>CT #</td>
                        <td><asp:TextBox runat="server" ID="txtCTNumber" ></asp:TextBox></td>
                        <td>Serial #</td>
                        <td><asp:TextBox runat="server" ID="txtSerialNumber" MaxLength="17"></asp:TextBox></td>
                        <td>City</td>
                        <td><asp:TextBox runat="server" ID="txtCity"></asp:TextBox></td>

                    </tr>
                    <tr>
                         <td>Capacity</td>
                        <td><asp:TextBox runat="server" ID="txtCapacity"></asp:TextBox></td>
                       <td>Unit #</td>
                        <td><asp:TextBox runat="server" ID="txtUnitNumber"></asp:TextBox></td>
                        <td>License State</td>
                        <td><asp:DropDownList EnableViewState="true" runat="server" ID="ddlState" DataSourceID="linqStates" 
                               Width="156px" DataTextField="StateText" DataValueField="StateID"></asp:DropDownList>
                            <asp:LinqDataSource ID="linqStates" runat="server" 
                                ContextTypeName="DataClassesDataContext" TableName="States">
                            </asp:LinqDataSource>
                        </td>

                  </tr>
                     <tr>
                         <td>Tank Type</td>
                        <td>
                            <asp:DropDownList runat="server" ID="ddlTankType"  Width="156px"
                                 ></asp:DropDownList>

                        </td> 
                        <td>Compartment</td>
                        <td><asp:TextBox runat="server" ID="txtCompartment"></asp:TextBox></td>
                         <td>License #</td>
                        <td><asp:TextBox runat="server" ID="txtLicenseNumber"></asp:TextBox></td>
                  </tr>
                      <tr>
                         <td>Manufacturer</td>
                        <td colspan="2">
                            <asp:DropDownList runat="server" ID="ddlManufacturer"  
                                 ></asp:DropDownList>

                        </td> 


                       <td><asp:CheckBox runat="server" ID="chkNoLogIn" Text="No Log In Associated" /></td>
                       <td></td> <td></td> 
                   </tr>
                   <tr><td>Company</td>
                        <td colspan="5"> <asp:DropDownList runat="server" ID="ddlCompany" ></asp:DropDownList></td>    
                 </tr>  
                 <tr>
                    <td colspan="3">
                    </td>
                    <td><asp:Button runat="server" ID="btnSearch" Text="Search" /></td>
                  </tr>
                </table>
            </div>

        </asp:Panel>
   </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
    </Triggers>  
  </asp:UpdatePanel>
  <br />

      <div style="padding-top:9px; width:100%; " id="divTankDetail" runat="server">
    <asp:UpdatePanel ID="updTankDetail" runat="server"  >
    <ContentTemplate>
        <ajaxToolkit:DropShadowExtender runat="server" ID="dsetank" TargetControlID="pnlTankDetail" TrackPosition="true" BehaviorID="pnlTankDetailHeader"></ajaxToolkit:DropShadowExtender>
        <ajaxToolkit:DragPanelExtender runat="server" ID="dpeTankDetail" TargetControlID="pnlTankDetail" DragHandleID="pnlTankDetailHeader"></ajaxToolkit:DragPanelExtender>
        <asp:Panel CssClass="TankpopupPosition" BackColor="LightBlue" Visible="false" runat="server" BorderColor="#3260a0" BorderWidth="2px"  Width="801px"  ID="pnlTankDetail" >
               <asp:Panel runat="server" BorderColor="#3260a0" BorderWidth="1px"  Width="800px"  ID="pnlTankDetailHeader">
             <div  >
            <div style="float:left; width:90%; background-color:#98B9C9; height:19px;">Tank Detail</div>
            <div style="float:right; width:10%; border-right-width:2px; border-width:1px; border-color:#3260a0; height:19px;background-color:#98B9C9; text-align:right">
                <asp:Button ID="btnClose" style="background:transparent; border:0px;" runat="server"   size="1" Font-Bold=true text="X" />&nbsp;
            </div> 

            <div style="padding-top:19px;"></div>
            </div>  
            </asp:Panel>
               <asp:Panel  runat="server"  Width="800px"  ID="pnlTankDetailBody">
                <div id="divTankDetailbody" runat="server" style="width:100%"  >
                 <br />
                 <table width="100%">
                    <tr>
                        <td>CT #</td>
                        <td><asp:TextBox TabIndex="10" runat="server" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" BackColor="Transparent" ID="txtCTNum" ReadOnly="true" ></asp:TextBox>
                        <asp:Label ID="lblCTNumber" runat="server" Text="*"></asp:Label>&nbsp</td>
                        <td>Serial #</td>
                        <td><asp:TextBox TabIndex="14" runat="server" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" ID="txtSeriaNum" MaxLength="17"></asp:TextBox>
                        <asp:Label ID="lblSerialNumber" runat="server" Text="*"></asp:Label>&nbsp</td>
                        <td>City</td>
                        <td><asp:TextBox runat="server" TabIndex="18" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" ID="txtOrignatedCity"></asp:TextBox></td>
                    </tr>
                    <tr>
                        <td>Capacity</td>
                        <td><asp:TextBox TabIndex="11" runat="server" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" ID="txtTanktCapacity"></asp:TextBox>
                        <asp:Label ID="lblCapacity" runat="server" Text="*"></asp:Label>&nbsp</td>
                         <td>Compartment</td>
                        <td><asp:TextBox runat="server" TabIndex="15" ID="txtCompartment2" BorderStyle="Inset" BorderColor="White" BorderWidth="2px"></asp:TextBox>
                      <asp:Label ID="lblCompartment" runat="server" Text="*"></asp:Label>&nbsp</td>

                                                    <td>License #</td>
                        <td><asp:TextBox runat="server" BorderStyle="Inset" TabIndex="19" BorderColor="White" BorderWidth="2px" ID="txtLicenseNum"></asp:TextBox></td>
                  </tr>
                     <tr>
                                                  <td>Tank Type</td>
                        <td>
                            <asp:DropDownList runat="server" TabIndex="12" ID="ddlTankType2" Width="156px" 
                                 DataTextField="TankTypeName" 
                                DataValueField="TankTypeName"></asp:DropDownList><asp:Label ID="lblTankType" runat="server" Text="*"></asp:Label>&nbsp
                         </td> 
                        <td>Unit #</td>
                        <td><asp:TextBox runat="server" TabIndex="16" BorderStyle="Inset" BorderColor="White" BorderWidth="2px" ID="txtUnitNum"></asp:TextBox></td>

                        <td>License State</td>
                        <td> 
                            <asp:DropDownList EnableViewState="true" Width="156px" TabIndex="20"  runat="server" ID="ddlLicenseState" DataSourceID="linqStates" 
                                DataTextField="StateText" DataValueField="StateID"></asp:DropDownList>                                


                            <asp:LinqDataSource ID="LinqDataSource1" runat="server" 
                                ContextTypeName="DataClassesDataContext" TableName="States">
                            </asp:LinqDataSource>
                        </td>

                  </tr>
                  <tr>
                        <td>Manufacturer</td>
                        <td colspan="1">
                            <asp:DropDownList runat="server" TabIndex="13" ID="ddlManufacturer2"  
                               >
                                 </asp:DropDownList><asp:Label ID="lblManufacturer" runat="server" Text="*"></asp:Label>&nbsp
                         </td> 
                        <td>Company</td>
                        <td colspan="3"> <asp:DropDownList runat="server" TabIndex="17" ID="ddlCompany2" ></asp:DropDownList><asp:Label ID="lblCompany2" runat="server" Text="*"></asp:Label></td>      

                   </tr>
                  <tr>
                    <td colspan="6" align="center"><br />
                        <asp:Label ID="lblChangeOwnership" Font-Size="Medium" runat="server"></asp:Label>
                        <br />
                        <asp:CheckBox ID="chkChangeOwnership" runat="server" Text="Changing ownership" ForeColor="Red" Font-Bold="true" />
                    </td>
                  </tr>
                  <tr>
                    <td colspan="6" align="center">
                        <br />
                     <asp:Button runat="server" ID="btnAdd" TabIndex="21" Text="Add" Width="60px" /> 
                     <asp:Button runat="server" ID="btnUpdate" TabIndex="22" Text="Update" Width="60px" /> 
                     <asp:Button runat="server" ID="btnChangeOnwership" TabIndex="23" Text="Change" Width="60px" /> 
                     <asp:Button runat="server" ID="btnCancel" TabIndex="24" Text="Cancel" Width="60px"  />
                     <br /><br />
                        <asp:GridView ID="grdTanks" runat="server" AllowPaging="True" 
                            AutoGenerateColumns="False" BackColor="Transparent" GridLines="None" 
                            PagerSettings-Mode="NumericFirstLast" PageSize="10" 
                            RowStyle-HorizontalAlign="left" Width="100%">
                            <AlternatingRowStyle CssClass="alternateItemStyle" />
                            <HeaderStyle CssClass="headerStyle" />
                            <PagerSettings Mode="NumericFirstLast" />
                            <RowStyle CssClass="itemStyle" />
                            <Columns>
                                <asp:BoundField DataField="CargoTankID" HeaderText="CT #" InsertVisible="False" 
                                    ReadOnly="True" SortExpression="CargoTankID" />
                                <asp:BoundField DataField="CompanyID" HeaderText="CompanyID" 
                                    SortExpression="CompanyID" Visible="false" />
                                <asp:BoundField DataField="OriginatedCity" HeaderText="OriginatedCity" 
                                    SortExpression="OriginatedCity" Visible="false" />
                                <asp:BoundField DataField="LicenseNumber" HeaderText="LicenseNumber" 
                                    SortExpression="LicenseNumber" Visible="false" />
                                <asp:BoundField DataField="LicenseState" HeaderText="LicenseState" 
                                    SortExpression="LicenseState" Visible="false" />
                                <asp:BoundField DataField="UnitNumber" HeaderText="Unit Number" 
                                    SortExpression="UnitNumber" Visible="false" />
                                <asp:TemplateField HeaderText="Company">
                                    <ItemTemplate>
                                        <%#DisplayCompanyName(Eval("CompanyID"))%>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="SerialNumber" HeaderText="Serial Number" 
                                    SortExpression="SerialNumber" />
                                <asp:BoundField DataField="Capacity" HeaderText="Capacity" 
                                    SortExpression="Capacity" />
                                <asp:TemplateField HeaderText="Manufacturer">
                                    <ItemTemplate>
                                        <%#DisplayManufacturer(Eval("ManufacturerID"))%>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="TankType" HeaderText="Tank Type" 
                                    SortExpression="TankType" Visible="false" />
                                <asp:BoundField DataField="Compartment" HeaderText="Compartment" 
                                    SortExpression="Compartment" Visible="false" />
                                <asp:BoundField DataField="DecalID" HeaderText="DecalID" 
                                    SortExpression="DecalID" Visible="false" />
                                <asp:TemplateField HeaderText="Decal Status">
                                    <ItemTemplate>
                                        <%#DisplayTestLink(Eval("CargoTankID"))%>
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                        </asp:GridView>
                     </td>

                  </tr>
                </table>

            </div>
            </asp:Panel>
        </asp:Panel>
   </ContentTemplate>
    <Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />

    </Triggers>  
  </asp:UpdatePanel>

これが私のコードビハインドです:

        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not Page.IsPostBack Then
        If (Me.Page.User.Identity.IsAuthenticated) Then
            Dim db As DataClassesDataContext = New DataClassesDataContext()

            Dim tanks = From t In db.CT_Tanks _
                        Select t

            Me.grdTanks.DataSource = tanks
            Me.grdTanks.DataBind()

            Dim tanktype = (From t In db.CT_TankTypes _
                            Select t).ToList

            ddlTankType.DataSource = tanktype
            ddlTankType.DataTextField = "TankTypeName"
            ddlTankType.DataValueField = "TankTypeName"
            ddlTankType.DataBind()
            ddlTankType.Items.Insert(0, "-- Select a Type --")
            ddlTankType2.DataSource = tanktype
            ddlTankType2.DataTextField = "TankTypeName"
            ddlTankType2.DataValueField = "TankTypeName"
            ddlTankType2.DataBind()
            ddlTankType2.Items.Insert(0, "-- Select a Type --")

            Dim manufacturer = (From m In db.CT_Manufacturers _
                               Select m).ToList

            ddlManufacturer.DataSource = manufacturer
            ddlManufacturer.DataTextField = "ManufacturerName"
            ddlManufacturer.DataValueField = "ManufacturerID"
            ddlManufacturer.DataBind()
            ddlManufacturer.Items.Insert(0, "-- Select a Manufacturer --")

            ddlManufacturer2.DataSource = manufacturer
            ddlManufacturer2.DataTextField = "ManufacturerName"
            ddlManufacturer2.DataValueField = "ManufacturerID"
            ddlManufacturer2.DataBind()
            ddlManufacturer2.Items.Insert(0, "-- Select a Manufacturer --")

            Dim companies = (From c In db.CT_Companies _
                             Where c.IsOwner = True _
                             Select c Order By c.CompanyName Ascending).ToList

            ddlCompany.DataSource = companies
            ddlCompany.DataTextField = "CompanyName"
            ddlCompany.DataValueField = "CompanyID"
            ddlCompany.DataBind()
            ddlCompany.Items.Insert(0, "-- Select a Company --")

            ddlCompany2.DataSource = companies
            ddlCompany2.DataTextField = "CompanyName"
            ddlCompany2.DataValueField = "CompanyID"
            ddlCompany2.DataBind()
            ddlCompany2.Items.Insert(0, "-- Select a Company --")

        End If
    End If

End Sub
4

4 に答える 4

0

グリッドビューをデータバインドした後、更新パネルがトリガーされていないようです

試す:

<asp:UpdatePanel ID="updTankDetail" runat="server" UpdateMode="Conditional">

次に、コードビハインドでput

updTankDetail.Update()
于 2012-07-18T16:58:27.013 に答える
0

タイトル: ページの読み込み時に asp.net グリッドビューが表示されない パネルを使用するコードで表示されid="ID="pnlTankDetail""、パネルID="pnlTankDetail"にはプロパティ Visible="False" so the gridviewgrdTanks can't show in page load. You should change toVisible="true to see gridview. And i think thediv tag not have propertyrunnat="server"`.Hope があります。

于 2014-01-09T02:19:11.880 に答える
0

確かではありませんが、これを追加すると役立つ場合があります

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
于 2012-07-18T16:35:28.487 に答える
0

パネルの下の更新パネル内にグリッドビューを配置してみました..

<asp:Panel ID="pnContainer" runat="server">
  <asp:UpdatePanel ID="UpdatePanel1" runat="server">
     <ContentTemplate>
             <asp:GridView ID="gvempgrade" runat="server" AutoGenerateColumns="False" GridLines="None" 
        onselectedindexchanged="GridView1_SelectedIndexChanged" 
        onrowcancelingedit="gvempgrade_RowCancelingEdit" 
        onrowediting="gvempgrade_RowEditing" 
        onrowupdating="gvempgrade_RowUpdating" ShowFooter="True" 
        onrowcommand="gvempgrade_RowCommand" 
        onrowdeleting="gvempgrade_RowDeleting">
        <FooterStyle BackColor="#A86E07" Font-Bold="True" ForeColor="White" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#603813" />
        <Columns>
            <asp:TemplateField HeaderText="<%$ Resources:Resources, SrNo %>" ItemStyle-CssClass="srcenteralg" ItemStyle-Width="30" HeaderStyle-Width="55" >
                <ItemTemplate >
                    <%# Container.DataItemIndex + 1 %>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField Visible="false">
                <ItemTemplate>
                    <asp:Label ID="lblid" runat="server" Text='<%# Bind("id_grd") %>'></asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ Resources:Resources, Grade %>"  >
                <ItemStyle HorizontalAlign="Center"  />
                <ItemTemplate>
                    <asp:Label ID="lblgrade" runat="server" Text='<%# Bind("grade_grd") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtempgrade" Width="55" CssClass="alphabetsOnlynospace" runat="server" Text='<%# Bind("grade_grd") %>'></asp:TextBox>
                </EditItemTemplate>
                <FooterTemplate >
                    <asp:TextBox ID="txtfempgrade" CssClass="alphabetsOnlynospace" runat="server" Width="55"></asp:TextBox>
                </FooterTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ Resources:Resources, Description %>" HeaderStyle-HorizontalAlign="Left">
                <ItemTemplate>
                    <asp:Label ID="lbldiscription" runat="server" Text='<%# Bind("description_grd") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtempdescription" CssClass="alphabetsOnly" runat="server" Text='<%# Bind("description_grd") %>'></asp:TextBox>
                </EditItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="txtfempdescription" CssClass="alphabetsOnly" runat="server"></asp:TextBox>
                </FooterTemplate>

            <HeaderStyle HorizontalAlign="Left"></HeaderStyle>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="<%$ Resources:Resources, Maxctc %>" HeaderStyle-HorizontalAlign="Center">
               <ItemStyle HorizontalAlign="Center" />
                <ItemTemplate>
                    <asp:Label ID="lblmaxctc" runat="server" Text='<%# Bind("max_ctc_grd") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtmaxctc" CssClass="numbersOnly" MaxLength="10" Width="100" runat="server" Text='<%# Bind("max_ctc_grd") %>'></asp:TextBox>
                </EditItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="txtfmaxctc" CssClass="numbersOnly" MaxLength="10" Width="100" runat="server"></asp:TextBox>
                </FooterTemplate>

            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="<%$ Resources:Resources, Minctc %>"  HeaderStyle-HorizontalAlign="Center">
               <ItemStyle HorizontalAlign="Center" />
                <ItemTemplate>
                    <asp:Label ID="lblminctc" runat="server" Text='<%# Bind("min_ctc_grd") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtminctc" MaxLength="10" CssClass="numbersOnly"  Width="100" runat="server" Text='<%# Bind("min_ctc_grd") %>'></asp:TextBox>
                </EditItemTemplate>
                <FooterTemplate>
                    <asp:TextBox ID="txtfminctc" MaxLength="10" CssClass="numbersOnly" Width="100" runat="server"></asp:TextBox>
                </FooterTemplate>

            <HeaderStyle HorizontalAlign="Center"></HeaderStyle>
            </asp:TemplateField>
            <asp:TemplateField ShowHeader="False" ItemStyle-Width="190px" FooterStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" >
                <ItemTemplate>
                    <asp:Button  ID="btnedit" runat="server" CausesValidation="True" CssClass="btngradiant" 
                        CommandName="Edit" Text="<%$ Resources:Resources, Edit %>"></asp:Button >
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:Button  ID="btnupdate" runat="server" CausesValidation="True" CssClass="btngradiant"
                        CommandName="Update" Text="Update" OnClientClick="return updatevalidation();" ></asp:Button >
                    &nbsp;<asp:Button  ID="btncancel" runat="server" CausesValidation="False" CssClass="btngradiant"
                        CommandName="Cancel" Text="Cancel"></asp:Button >
                </EditItemTemplate>
                <FooterTemplate >

                    <asp:Button ID="btninsert" runat="server" Text="<%$ Resources:Resources, Add %>" CommandName="Add"   CssClass="btngradiant" OnClientClick="return validation();" />
                </FooterTemplate>
            </asp:TemplateField>

                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:Button ID="LinkButton2" runat="server" CausesValidation="False" CssClass="btngradiant" OnClientClick='return confirm("Are you sure you want to delete this entry?");'
                            CommandName="Delete" Text="<%$ Resources:Resources, Delete %>"></asp:Button>
                    </ItemTemplate>
            </asp:TemplateField>
            </Columns>
        <PagerStyle BackColor="#A86E07" ForeColor="White" HorizontalAlign="Center" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#A86E07" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#d9d9d9" />
        <AlternatingRowStyle BackColor="White" ForeColor="#A86E07" />
    </asp:GridView>

    </ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>

コードビハインド:

On pageLoad()

 if (!Page.IsPostBack)
        {
            DataTable dtfetch = emp.Fetchreord();
            gvempgrade.DataSource = dtfetch;
            gvempgrade.DataBind();
        }

注: DLL が見つからないという意味でエラーが発生するのでextendercontrolbase.cs 、すべての Extender コントロールにコメントを付けて、動作するかどうかを確認してください。

于 2012-07-19T06:11:50.483 に答える