如何在html表中编写网格视图?

时间:2015-03-20 17:35:00

标签: c# html asp.net gridview

我有这个网格视图,我想把它写成html表,但我不知道如何 我想在(table,thead,td和tr)标签中写它。我想知道如何在html表中编写它

 <asp:GridView ID="GridView1" runat="server" AllowPaging="True" EnableSortingAndPagingCallbacks="false" 
                           BackColor="White" BorderColor="#999999" 
                           ViewStateMode="Enabled" width="713px" CellPadding="3" 
                           HorizontalAlign="Center" AllowSorting="True" OnPageIndexChanging="GridView1_PageIndexChanging"
                           BorderStyle="Solid" BorderWidth="1px" ForeColor="Black"  ShowFooter="True" 
                           GridLines="Vertical" AutoGenerateColumns="False" PageSize="20"  onrowdatabound="GridView1_RowDataBound"
                         Height="16px" >
                           <Columns>
        <asp:TemplateField HeaderText="الرصيد">
            <ItemTemplate>
                <asp:Label runat="server" ID="lblTotal" Text=""></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
         <asp:TemplateField HeaderText="مدين">
            <ItemTemplate>
                <div style="padding:0 0 5px 0"> <asp:Label ID="debit" runat="server" Text='<%# (Eval("stat_flag").ToString() =="d" ) ? string.Format("{0:0.000}",float.Parse(Eval("stat_amount").ToString())): "0.00" %>'></asp:Label></div>
 <div><asp:Label ID="lblGrandTotal" runat="server" /></div>
            </ItemTemplate>
             <FooterTemplate>
        <asp:Label ID="totallblDebAmount" runat="server" />
     </FooterTemplate>   
        </asp:TemplateField>
              <asp:TemplateField HeaderText="دائن">
            <ItemTemplate>
                  <div style="padding:0 0 5px 0"><asp:Label ID="credit"   
           runat="server" Text='<%# (Eval("stat_flag").ToString() =="c" ) ?   
     string.Format("{0:0.000}",float.Parse(Eval("stat_amount").ToString())):   
           "0.00" %>'></asp:Label></div>
            </ItemTemplate>
             <FooterTemplate>
        <asp:Label ID="totallblCredAmount" runat="server" />
     </FooterTemplate>   
        </asp:TemplateField>
                                <asp:BoundField  DataField="stat_desc" 
                                HeaderText="البيان" ItemStyle-Font-   
     Size="Small">
    <ItemStyle Font-Size="Small"></ItemStyle>
                               </asp:BoundField>
                                <asp:BoundField  DataField="trans_name" 
                             HeaderText=" نوع السند " ItemStyle-Font-  
                  Size="Small">
    <ItemStyle Font-Size="Small"></ItemStyle>
                               </asp:BoundField>
                            <asp:BoundField  DataField="serial" 
                             HeaderText=" رقم السند " ItemStyle-Font-   
            Size="Small">
         <ItemStyle Font-Size="Small"></ItemStyle>
                               </asp:BoundField>
                                 <asp:TemplateField HeaderText="التاريخ">
            <ItemTemplate>
                 <asp:Label ID="date" runat="server" Text='<%#Eval("stat_date" ,"{0:dd/MM/yyyy}" )%>'> ></asp:Label>
            </ItemTemplate>
             <FooterTemplate>
   <div style="padding:0 0 5px 0"><asp:Label ID="Label5" Text="اجمالي الصفحة     
  " runat="server" /></div>
     </FooterTemplate>   
        </asp:TemplateField>
                           </Columns>
                             <FooterStyle BackColor="#336699" Font-  
  Bold="True" ForeColor="White" HorizontalAlign="right" />
                           <RowStyle BorderColor="Black" BorderStyle="Solid" 
    BorderWidth="1px" />
                           <AlternatingRowStyle BackColor="#DDDDDD" />

                           <HeaderStyle BackColor="#aaaaaa" Font-Bold="True"   
  HorizontalAlign="Center" 
                               VerticalAlign="Middle" ForeColor="Black"    
    BorderColor="Black" BorderStyle="Solid" BorderWidth="1px"/>
                           <PagerStyle BackColor="#999999" ForeColor="Blue"   
     HorizontalAlign="Left" Font-Bold="True" 
                           Font-Underline="False" BorderStyle="Solid" 
    BorderWidth="1px" BorderColor="#666666" />
                       </asp:GridView>

举个例子,我想用html格式写这个格式

   <TABLE CELLPADDING=6>
  <THEAD>
   <TR> <TH>Weekday</TH> <TH>Date</TH> <TH>Manager</TH> <TH>Qty</TH> </TR>
</THEAD>
<TBODY>
 <TR> <TD>Mon</TD> <TD>09/11</TD> <TD>Kelsey</TD>  <TD>639</TD>  </TR>
 <TR> <TD>Tue</TD> <TD>09/12</TD> <TD>Lindsey</TD> <TD>596</TD>  </TR>
 <TR> <TD>Wed</TD> <TD>09/13</TD> <TD>Randy</TD>   <TD>1135</TD> </TR>
 <TR> <TD>Thu</TD> <TD>09/14</TD> <TD>Susan</TD>   <TD>1002</TD> </TR>
  <TR> <TD>Fri</TD> <TD>09/15</TD> <TD>Randy</TD>   <TD>908</TD>  </TR>
   <TR> <TD>Sat</TD> <TD>09/16</TD> <TD>Lindsey</TD> <TD>371</TD>  </TR>
     <TR> <TD>Sun</TD> <TD>09/17</TD> <TD>Susan</TD>   <TD>272</TD>  </TR>
        </TBODY>
      <TFOOT id="table_footer">
       <TR> <TH ALIGN=LEFT COLSPAN=3>Total</TH> <TH>4923</TH> </TR>
     </TFOOT>
     </TABLE>
     </body>
     </html>

1 个答案:

答案 0 :(得分:2)

也许您可以创建GridView,运行项目,然后右键单击浏览器屏幕和Inspect Element。然后,您将看到生成的Html代码。

或者您可以访问此网站,其中有一个可以帮助您的示例:Export Gridview To HTML File Using ASP.Net C#