3
我在我的頁面中嵌套gridview。第一個像頭一樣使用,所以這將顯示段名稱。第二個用於顯示段細節。一切都很好,除了我在設計第一個網格時遇到問題。我想在此頁面顯示數據的方式是 段(換行符) 詳細信息嵌套gridview C#
但它在一行中顯示爲段詳細信息。我將如何使網格出現在佔用頁面整個寬度的兩行中。這是目前如何設置的。
<asp:GridView ID="gvSegments" runat="server" AutoGenerateColumns="false" GridLines="None" Width="900px" OnRowDataBound="gvSegments_RowDataBound">
<Columns>
<asp:TemplateField ShowHeader="false">
<ControlStyle Width="140px" />
<ItemTemplate>
<asp:HiddenField ID="hfSegmentId" runat="server" Value='<%# Bind("SegmentId") %>' />
<asp:Label ID="lblSegmentDesc" runat="server" Text='<%# Bind("SegmentDesc") %>' Font-Bold="true" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="false">
<ItemTemplate>
<asp:GridView ID="gvSegmentDetails" runat="server" AutoGenerateColumns="false" GridLines="None" OnRowDataBound="gvSegmentDetails_RowDataBound" Font-Size="11px">
<Columns>
<asp:TemplateField ShowHeader="false">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:CheckBox ID="chkAction" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Medium">
<ControlStyle Font-Size="11px" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:HiddenField ID="hfSegmentId" runat="server" Value='<%# Bind("SegmentId") %>' />
<asp:HiddenField ID="hfSegmentDetailId" runat="server" Value='<%# Bind("SegmentDetailId") %>' />
<asp:Label ID="lblMediaType" runat="server" Text='<%# Bind("MediaTypeDesc") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Cost per Piece">
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label ID="lblCostPerPiece" runat="server" Text='<%# Bind("CostPerPiece") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="false">
<ItemTemplate>
<asp:LinkButton ID="lnkEditMedia" runat="server" Text="Details" OnClick="lnkEditMedia_Click" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Advertising Months">
<ControlStyle Font-Size="11px" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label ID="lblAdvertisingMonths" runat="server" Text='<%# Bind("Months") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Budget">
<ControlStyle Width="70px" Font-Size="11px" />
<ItemStyle HorizontalAlign="Center" />
<ItemTemplate>
<asp:Label ID="txtBudget" runat="server" Text='<%# Bind("DropAmount", "{0:$###,###,##0.00}") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Total Quantity">
<ItemStyle HorizontalAlign="Center" />
<ControlStyle Width="50px" Font-Size="11px" />
<ItemTemplate>
<asp:Label ID="lblTotalQty" runat="server" Text='<%# Bind("DropQuantity") %>' />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Select Creative">
<ControlStyle Font-Size="11px" />
<ItemTemplate>
<asp:DropDownList ID="ddrCreative" runat="server" AppendDataBoundItems="true" OnSelectedIndexChanged="ddrCreative_SelectedChanged" AutoPostBack="true">
<asp:ListItem Value="-1" Text="Select One" Selected="True" />
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField ShowHeader="false">
<ControlStyle Font-Size="11px" />
<ItemTemplate>
<asp:HiddenField ID="hfCreativeUrl" runat="server" />
<asp:HyperLink ID="hprCreativeUrl" runat="server" Target="_blank" Text="Click here" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle BackColor="#a73e20" ForeColor="White" />
<AlternatingRowStyle BackColor="#E4E4E4" />
<RowStyle BackColor="#F7F7F7" />
</asp:GridView>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
冷卻整個窗口!從來沒有想過這件事。謝謝德里克。這工作。 – bladerunner
很高興我能幫忙:) –