asp.net GridView的使用

來源:互聯網
上載者:User

1.首先一個例子

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
            CssClass="vip_table" GridLines="None" BorderStyle="None" CellPadding="0"
            ShowHeader="False">
            <Columns>
                <asp:TemplateField HeaderText="">
                    <ItemStyle  />
                    <HeaderStyle  />
                    <ItemTemplate>
                       <table class="vip_table vip_tablebody">
                            <tr>
                            <td width="30px" class="vip_bodynum"><%#Convert.ToInt32(Container.DataItemIndex)+1%></td>
                            <td width="90px" class="vip_bodytd"><a href="#" class="a_detail"><%#Eval("Base_tabletNumber")%></a></td>
                            <td width="120px" class="vip_bodytd"><%# Eval("Base_Family")%></td>
                            <td width="120px" class="vip_bodytd"><%# Eval("Base_MainStyleNo")%></td>
                            <td width="60px" class="vip_bodytd"><%# Eval("Base_VehicleBirthDay")%></td>
                            <td width="120px" class="vip_bodytd vip_bodytdprice"><%# string.Format("{0:C2}",Eval("Base_ExpectPrice")).Split('.')[0]%></td>
                            <td width="90px" class="vip_bodytd"><a href="#" class="a_detail">查看</a></td>
                            <td width="130px" class="vip_bodytd">
                                <input type="text" name="price" class="vip_price fonttext" /></td>
                            <td width="">
                                <input type="submit" value="" class="vip_commit" /></td>
                            </tr>
                        </table>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>

        </asp:GridView>

2.GridView涉及的小問題

   去邊框:BorderStyle="None" CellPadding="0" GridLines ="None"

   增加自動序號:

              <ItemTemplate>
              <%#Container.DataItemIndex+1%>
              </ItemTemplate>

   e.Row.Cells[0]

   去表頭:this.dataGridView1.ColumnHeadersVisible = false;

          ShowHeader="False"

   設定樣式:

                  RowStyle 就是普通的行的樣式,跟你設定tr一樣的。 SelectedRowStyle 選中行的樣式,不知道是不是滑鼠放在某行上的樣式 PagerStyle 底部的樣式,最後一行應該是 HeaderStyle 頭部 的樣式,就是標題啊,比如 編號,姓名, AlternatingRowStyle 交替項的樣式。

 

出處:http://www.cnblogs.com/wuchao/archive/2012/08/15/2640254.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.