GrideView設置行,表頭

前臺代碼

<asp:GridView ID="gvShow"  BorderStyle="none"  runat="server" 
       AutoGenerateColumns="False" width="100%" border="1" cellpadding="4" 
       AllowPaging="True" PageSize="10" onrowdatabound="gvShow_RowDataBound" onpageindexchanging="gvShow_PageIndexChanging"
                                         ForeColor="#fe8300" CellSpacing="4"  
       HeaderStyle-HorizontalAlign="Center"  OnRowCreated="gvShow_RowCreated"  >
   <RowStyle  BorderStyle="Groove" BorderColor="#f9c99b"/>
                                       
                                        <Columns>
                                            <asp:BoundField DataField="MoneyPrice" HeaderText="Top-Up Price (USD)"  />
                                            <asp:BoundField DataField="BuyGamePointNum" HeaderText="Game Points" />
                                            <asp:BoundField DataField="PayDate" HeaderText="Top-up Date" />
                                        </Columns> 
                                        <PagerSettings FirstPageText="first" LastPageText="last" NextPageText="next" 
                                            PreviousPageText="prec." Mode="NextPreviousFirstLast" />
                                        <PagerStyle CssClass="txet_new1" HorizontalAlign="Center" />
                                        <HeaderStyle CssClass="txet_new1" HorizontalAlign="Center" VerticalAlign="Middle" />
                                        <RowStyle CssClass="txet_new1" HorizontalAlign="Center" VerticalAlign="Middle" />
                                      
                                    </asp:GridView>



後臺代碼

  protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GridBind();
            }


        }




        private void GridBind()
        {
            PortalDal.OnlinePay.PayOrder pay = new PortalDal.OnlinePay.PayOrder();
            DataTable dt = pay.GetOnlinePayOrderInfo(MemberSessionCookie.GetLoginSessionUserID(), 10);
            if (dt.Rows.Count > 0)
            {
                DataTable dt2 = ConvertPrice(dt);
                gvShow.DataSource = dt2;
                gvShow.DataBind();
            }
            else
            {
                this.LaiError.Style.Add("display", "table-row");
            }
        }


        protected void btnSearch_Click(object sender, EventArgs e)
        {
            GridBind();
        }


        protected void gvShow_RowDataBound(object sender, GridViewRowEventArgs e)
        {


        }


        protected void gvShow_PageIndexChanging(object sender, GridViewPageEventArgs e)
        {
            gvShow.PageIndex = e.NewPageIndex;
            GridBind();
        }


效果圖


效果圖:

發佈了28 篇原創文章 · 獲贊 4 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章