2015-09-10 26 views
0

我綁定GridView然後打開選定行的詳細視圖的模態PopUp。在DetailsView(或GridView)中渲染數據將SideBySide渲染爲C#中的兩個部分或兩個列#

我的DetailsView如下所示。

  <asp:DetailsView ID="DetailsView1" runat="server" CssClass="table table-bordered table-hover" 
          BackColor="White" ForeColor="Black" FieldHeaderStyle-Wrap="false" FieldHeaderStyle-Font-Bold="true" 
          FieldHeaderStyle-BackColor="LavenderBlush" FieldHeaderStyle-ForeColor="Black" 
          BorderStyle="Groove" AutoGenerateRows="False"> 
          <Fields> 
           <asp:BoundField HeaderText="Date" DataField="Date" /> 
           <asp:BoundField HeaderText="Feeder Name" DataField="Feeder Name" /> 
           <asp:BoundField HeaderText="Meter Serial No" DataField="Meter Serial No" /> 
           <asp:BoundField HeaderText="Time" DataField="Time" Visible="false"/> 
           <asp:BoundField HeaderText="Class Of Voltage" DataField="Class Of Voltage" /> 
           <asp:BoundField HeaderText="Voltage-R" DataField="Voltage-R" /> 
           <asp:BoundField HeaderText="Voltage-Y" DataField="Voltage-Y" /> 
           <asp:BoundField HeaderText="Voltage-B" DataField="Voltage-B" /> 
           <asp:BoundField HeaderText="Line Current-R" DataField="Line Current-R" /> 
           <asp:BoundField HeaderText="Line Current-Y" DataField="Line Current-Y" /> 
           <asp:BoundField HeaderText="Line Current-B" DataField="Line Current-B" /> 
           <asp:BoundField HeaderText="Neutral Current" DataField="Neutral Current" /> 
           <asp:BoundField HeaderText="Act. Power" DataField="Act. Power" /> 
           <asp:BoundField HeaderText="React. Power" DataField="React. Power" /> 
           <asp:BoundField HeaderText="Act. Power(tot)" DataField="Act. Power(tot)" /> 
           <asp:BoundField HeaderText="App. Power" DataField="App. Power" /> 
           <asp:BoundField HeaderText="PF-R" DataField="PF-R" /> 
           <asp:BoundField HeaderText="PF-Y" DataField="PF-Y" /> 
           <asp:BoundField HeaderText="PF-B" DataField="PF-B" /> 
           <asp:BoundField HeaderText="Avg. PF" DataField="Avg. PF" /> 
           <asp:BoundField HeaderText="Freq." DataField="Freq." /> 
           <asp:BoundField HeaderText="Act. Import" DataField="Act. Import" /> 
           <asp:BoundField HeaderText="Act. Export" DataField="Act. Export" /> 
           <asp:BoundField HeaderText="Act. Import(F)" DataField="Act. Import(F)" /> 
           <asp:BoundField HeaderText="Act. Export(F)" DataField="Act. Export(F)" /> 
           <asp:BoundField HeaderText="Reactive(Q1)" DataField="Reactive(Q1)" /> 
           <asp:BoundField HeaderText="Reactive(Q2)" DataField="Reactive(Q2)" /> 
           <asp:BoundField HeaderText="Reactive(Q3)" DataField="Reactive(Q3)" /> 
           <asp:BoundField HeaderText="Reactive(Q4)" DataField="Reactive(Q4)" /> 
           <asp:BoundField HeaderText="Act. Import" DataField="Act. Import" /> 
           <asp:BoundField HeaderText="App. Export" DataField="App. Export" /> 
           <asp:BoundField HeaderText="Cons. Act. Import" DataField="Cons. Act. Import" /> 
           <asp:BoundField HeaderText="Cons. Act. Export" DataField="Cons. Act. Export" /> 
           <asp:BoundField HeaderText="Act. Import Demand" DataField="Act. Import Demand" /> 
           <asp:BoundField HeaderText="Act. Export Demand" DataField="Act. Export Demand" /> 
           <asp:BoundField HeaderText="Cons. Act. Import(F)" DataField="Cons. Act. Import(F)" /> 
           <asp:BoundField HeaderText="Cons. Act. Export(F)" DataField="Cons. Act. Export(F)" /> 
           <asp:BoundField HeaderText="Cons. Reactive (Q1)" DataField="Cons. Reactive (Q1)" /> 
           <asp:BoundField HeaderText="Cons. Reactive (Q2)" DataField="Cons. Reactive (Q2)" /> 
           <asp:BoundField HeaderText="Cons. Reactive (Q3)" DataField="Cons. Reactive (Q3)" /> 
           <asp:BoundField HeaderText="Cons. Reactive (Q4)" DataField="Cons. Reactive (Q4)" /> 
           <asp:BoundField HeaderText="Cons. App. Import" DataField="Cons. App. Import" /> 
           <asp:BoundField HeaderText="Cons. App. Export" DataField="Cons. App. Export" /> 
          </Fields> 
         </asp:DetailsView> 

這裏在下面如何我的DetailesView呈現數據如下。

enter image description here

問題是由於我的數據是兩個較長DetailedView也很長。 所以我在這裏我想要我如何渲染DetailsView數據SideBySide。

(實施例:

現在我獲得的DetailsView如下

  1. Ç

  2. d

  3. Ë

但我想,以使其如下

1.A 2.B

3.C 4.D

5.E

那麼,任何人都可以給我這個想法來渲染DetailsView。

在此先感謝。

+0

您不能以這種方式操作綁定字段。雖然有解決方法,但這會使您的代碼不必要地複雜。爲什麼不在詳細視圖中使用垂直滾動條? – Codeek

+0

還有一件事..是你只是轉換視圖?那就是當你點擊細節時,同一記錄顯示爲兩個字段記錄? – Codeek

+0

是Codeek ..相同的記錄(哪裏(在哪個記錄中)按鈕單擊)我在Details View中看到。而且我已經保持垂直滾動條,但要求如上所述。是否有我可以使用更多列創建我的自定義控件正如我想呈現我的數據。如果是,那麼請只幫助我幾個步驟,我必須做的。 –

回答

0

對不起,最近幾天沒有上線。 改爲使用Repeater。這將很容易地完成這項工作。你將不得不使用表,TR和TD標籤和DataItem的方法,讓您的值:

<asp:Repeater id="MyRptr" runat="server"> 
<HeaderTemplate> 
<table border="1" width="100%"> 
<tr> 
<th>Field</th> 
<th>Value</th> 
</tr> 
</HeaderTemplate> 

<ItemTemplate> 
<tr> 
<td>Date</td> 
<td><%#Container.DataItem("Date")%></td> 
</tr> 
<tr> 
<td>Feeder Name</td> 
<td><%#Container.DataItem("Feeder")%></td> 
</tr> 
.... 
<tr> 
..... 
</tr> 
</ItemTemplate> 

<FooterTemplate> 
</table> 
</FooterTemplate> 

</asp:Repeater> 

,並設置MyRptr的DataSource,就像你做的GridView,然後的DataBind()。

參考:Repeater

+0

雅感謝Codeek ..這是很好的,我可以創建設計,因爲我想使用中繼器。 –