国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開(kāi)APP
userphoto
未登錄

開(kāi)通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開(kāi)通VIP
C# GridView詳解
  • 前臺(tái)代碼

Java代碼
 
  1. <!--id用于綁定數(shù)據(jù)的標(biāo)識(shí),-->   
  2. <asp:GridView ID="gvLog" runat="server" AutoGenerateColumns="False" CellPadding="3" CellSpacing="1"  
  3.     Width="100%" BackColor="#F3F3F3" BorderWidth="0px" OnRowDeleting="gvLog_RowDeleting" OnRowDataBound="gvLog_RowDataBound">   
  4.     <RowStyle BackColor="White" />   
  5.     <Columns>   
  6.      <!--綁定列-->   
  7.         <asp:BoundField DataField="OperId" >   
  8.             <ItemStyle CssClass="display:none;" />   
  9.         </asp:BoundField>   
  10.         <asp:BoundField HeaderText="No">   
  11.             <ItemStyle Width="30px" HorizontalAlign="Center" />   
  12.         </asp:BoundField>   
  13.         <!--帶鏈接的綁定列,DataNavigateUrlFields表示要傳遞的參數(shù),多個(gè)參數(shù)用逗號(hào)分割開(kāi)-->   
  14.         <asp:HyperLinkField DataNavigateUrlFields="OperId,operName" DataNavigateUrlFormatString="OperatorEdit.aspx?OperId={0}&operName={1}"  
  15.             DataTextField="OperName" HeaderText="登錄名稱" >   
  16.             <ItemStyle Width="100px" />   
  17.         </asp:HyperLinkField>   
  18.         <asp:BoundField HeaderText="真實(shí)名稱" DataField="TrueName">   
  19.             <ItemStyle Width="100px" />   
  20.         </asp:BoundField>   
  21.         <asp:BoundField HeaderText="備注" DataField="OperMemo" />   
  22.         <asp:HyperLinkField HeaderText="授權(quán)" NavigateUrl="OperatorRole.aspx" Text="角色授權(quán)" DataNavigateUrlFields="OperId" DataNavigateUrlFormatString="OperatorRole.aspx?operId={0}">   
  23.             <ItemStyle Width="60px" HorizontalAlign="Center" />   
  24.         </asp:HyperLinkField>   
  25.         <!--事件綁定操作,該例子是刪除時(shí)間-->   
  26.         <asp:CommandField HeaderText="操作" ShowDeleteButton="True">   
  27.             <ItemStyle Width="40px" HorizontalAlign="Center" />   
  28.         </asp:CommandField>   
  29.     </Columns>   
  30.     <SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />   
  31.     <!--表格頭部樣式-->   
  32.     <HeaderStyle BackColor="#CCCCCC" Font-Bold="True" ForeColor="#FFFEEE" Height="15px" />   
  33.    <!--隔行變色-->   
  34.     <AlternatingRowStyle BackColor="#F9F9F9" />   
  35. </asp:GridView>  

  • 后臺(tái)代碼---綁定gridview

Java代碼
 
  1. DataSet ds = operServices.GetList("");   
  2. DataView dv = new DataView(ds.Tables[0]);   
  3. ///獲取或設(shè)置用于篩選在 DataView 中查看哪些行的表達(dá)式。   
  4. dv.RowFilter = "isdel=0";   
  5.   
  6. this.gvLog.DataSource = dv;   
  7. this.gvLog.DataBind();  

注1:DataView 使您能夠創(chuàng)建 DataTable 中所存儲(chǔ)的數(shù)據(jù)的不同視圖,這種功能通常用于數(shù)據(jù)綁定應(yīng)用程序。使用 DataView,您可以使用不同排序順序顯示表中的數(shù)據(jù),并且可以按行狀態(tài)或基于篩選器表達(dá)式來(lái)篩選數(shù)據(jù)。

注2:如果獲取不到GridView隱藏控件的值,則需要加入以下一段代碼
Java代碼
 
  1. ///該方法名稱應(yīng)該與你綁定的時(shí)間名稱一致   
  2. protected void gvLog_RowDataBound(object sender, GridViewRowEventArgs e)   
  3. {   
  4.    if (e.Row.RowType == DataControlRowType.DataRow || e.Row.RowType == DataControlRowType.Header)   
  5.     {   
  6.         ///指定隱藏列,并賦值   
  7.         e.Row.Cells[0].Visible = false;   
  8.         e.Row.Cells[1].Visible = false;   
  9.     }   
  10. }  


注3:如果我們要根據(jù)某個(gè)條件去改變表格某個(gè)值的樣式,可以在行綁定時(shí)間方法中加入如下代碼,如:
Java代碼
 
  1. protected void gvLog_RowDataBound(object sender, GridViewRowEventArgs e)   
  2. {   
  3.     if (e.Row.RowIndex != -1)   
  4.     {   
  5.         if (Convert.ToInt16(e.Row.Cells[1].Text.ToString()) == 1)   
  6.         {   
  7.             e.Row.Cells[6].Text = "<font color='red'><b>" + e.Row.Cells[6].Text.ToString() + "</b></font>";   
  8.         }   
  9.     }   
本站僅提供存儲(chǔ)服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊舉報(bào)。
打開(kāi)APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
ASP.NET查詢ACCESS數(shù)據(jù)庫(kù)的內(nèi)容并在DATAVIEW中顯示出來(lái)
后臺(tái)判斷GridView某列在前臺(tái)顯示信息
GridView 72般絕技
點(diǎn)擊textbox彈出模態(tài)窗口,選擇后返回主頁(yè)面并賦值textbox
GridView點(diǎn)擊行按鈕的時(shí)候固定滾動(dòng)條的實(shí)現(xiàn)方法
GridView
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長(zhǎng)圖 關(guān)注 下載文章
綁定賬號(hào)成功
后續(xù)可登錄賬號(hào)暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服