PIXNET Logo登入

奶茶妹妹的小窩

跳到主文

奶茶妹妹的小窩僅供記錄各種閒雜事務

部落格全站分類:生活綜合

  • 相簿
  • 部落格
  • 留言
  • 名片
  • 9月 11 週一 201711:21
  • [C#]GridView裡可使用的自行列欄位設計類型

      GridView中,若將AutoGenerateColumns設為False,則所有欄位自行設計,可使用的類型如下表所示,且必須在<Columns></Columns>中進行編輯,才能使GridView正常顯示資料內容。



列欄類型
說明 


Boundfield
GridView自訂預設欄位類型。


TemplateField
使用者自定義欄位類型時所預先填入的類型。


CheckBoxField
在GridView增加核取方塊,為boolean值 。


HyperLinkField
將欄位值設為超連結,可連結到別的頁面。 


ImageField
為GridView設定圖項顯示。 


ButtonField
為GridView設定按鈕控制項,「新增」或「移除」按鈕。


CommandField
用來「選擇」、「編輯」或「刪除」的命令按鈕。


(繼續閱讀...)
文章標籤

奶茶妹妹 發表在 痞客邦 留言(0) 人氣(727)

  • 個人分類:GridView
▲top
  • 9月 11 週一 201711:21
  • [C#]GridView裡可使用的自行列欄位設計類型

      GridView中,若將AutoGenerateColumns設為False,則所有欄位自行設計,可使用的類型如下表所示,且必須在<Columns></Columns>中進行編輯,才能使GridView正常顯示資料內容。



列欄類型
說明 


Boundfield
GridView自訂預設欄位類型。


TemplateField
使用者自定義欄位類型時所預先填入的類型。


CheckBoxField
在GridView增加核取方塊,為boolean值 。


HyperLinkField
將欄位值設為超連結,可連結到別的頁面。 


ImageField
為GridView設定圖項顯示。 


ButtonField
為GridView設定按鈕控制項,「新增」或「移除」按鈕。


CommandField
用來「選擇」、「編輯」或「刪除」的命令按鈕。


(繼續閱讀...)
文章標籤

奶茶妹妹 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:GridView
▲top
  • 9月 08 週五 201717:07
  • [C#]GridView隱藏欄位之一 OnRowDataBound

      GridView屬性中AutoGenerateColumns設為False時,內容欄位格式均為自行設計Coding,故若有Primary Key或是欲隱藏不顯示的欄位內容,但欄位值本身仍需做計算或供其他網頁使用,可採用以下方式,將欄位標題及內容隱藏,不顯示於畫面上,但該欄位所有的數值或文字,仍可Coding使用。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
// 隱藏標題列中某特定欄位
// 1
e.Row.Cells[3].Visible = false;
// 2
foreach (TableCell col in e.Row.Cells)
{
if ((((DataControlFieldCell)(col)).ContainingField).HeaderText == "標題文字4")
{
col.Visible = false;
}
}
// 3
foreach (DataControlFieldCell col in e.Row.Cells)
{
if ((col.ContainingField).HeaderText == "標題文字4")
{
col.Visible = false;
}
}

// 4(using System.Linq;) Page_Load中可使用

e.Row.Cells.Cast()
.Where(c => c.Text == "標題文字4")
.ToList()
.ForEach(col => col.Visible = false);

}
if (e.Row.RowType == DataControlRowType.DataRow)
{

}


}
(繼續閱讀...)
文章標籤

奶茶妹妹 發表在 痞客邦 留言(0) 人氣(0)

  • 個人分類:GridView
▲top
  • 9月 08 週五 201717:07
  • [C#]GridView隱藏欄位之一 OnRowDataBound

      GridView屬性中AutoGenerateColumns設為False時,內容欄位格式均為自行設計Coding,故若有Primary Key或是欲隱藏不顯示的欄位內容,但欄位值本身仍需做計算或供其他網頁使用,可採用以下方式,將欄位標題及內容隱藏,不顯示於畫面上,但該欄位所有的數值或文字,仍可Coding使用。
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
// 隱藏標題列中某特定欄位
// 1
e.Row.Cells[3].Visible = false;
// 2
foreach (TableCell col in e.Row.Cells)
{
if ((((DataControlFieldCell)(col)).ContainingField).HeaderText == "標題文字4")
{
col.Visible = false;
}
}
// 3
foreach (DataControlFieldCell col in e.Row.Cells)
{
if ((col.ContainingField).HeaderText == "標題文字4")
{
col.Visible = false;
}
}

// 4(using System.Linq;) Page_Load中可使用

e.Row.Cells.Cast()
.Where(c => c.Text == "標題文字4")
.ToList()
.ForEach(col => col.Visible = false);

}
if (e.Row.RowType == DataControlRowType.DataRow)
{

}


}
(繼續閱讀...)
文章標籤

奶茶妹妹 發表在 痞客邦 留言(0) 人氣(1,350)

  • 個人分類:GridView
▲top
«12

個人資訊

奶茶妹妹
暱稱:
奶茶妹妹
分類:
生活綜合
好友:
累積中
地區:

個人資訊

奶茶妹妹
暱稱:
奶茶妹妹
分類:
生活綜合
好友:
累積中
地區:

文章分類

toggle VisualStudio (1)
  • Visual Studio (1)
toggle VisualStudio (1)
  • Visual Studio (1)
toggle JavaScript (1)
  • JavaScript (1)
toggle JavaScript (1)
  • JavaScript (1)
toggle C# (2)
  • Config (0)
  • GridView (3)
toggle C# (2)
  • Config (0)
  • GridView (3)
  • Dos相關 (1)
  • Dos相關 (1)
  • ASP.Net (1)
  • ASP.Net (1)
  • 未分類文章 (1)

文章分類

toggle VisualStudio (1)
  • Visual Studio (1)
toggle VisualStudio (1)
  • Visual Studio (1)
toggle JavaScript (1)
  • JavaScript (1)
toggle JavaScript (1)
  • JavaScript (1)
toggle C# (2)
  • Config (0)
  • GridView (3)
toggle C# (2)
  • Config (0)
  • GridView (3)
  • Dos相關 (1)
  • Dos相關 (1)
  • ASP.Net (1)
  • ASP.Net (1)
  • 未分類文章 (1)

最新文章

  • 資料夾內檔案名全複製
  • 資料夾內檔案名全複製
  • [快速]Visual Studio 快捷鍵列表
  • [快速]Visual Studio 快捷鍵列表
  • [ASP.Net]Eval和Bind之間的差異
  • [ASP.Net]Eval和Bind之間的差異
  • [JavaScript]執行前端程式時出現的錯誤:Unexpected end of input
  • [JavaScript]執行前端程式時出現的錯誤:Unexpected end of input
  • [C#]GridView隱藏欄位之二 RowCreated
  • [C#]GridView隱藏欄位之二 RowCreated

最新文章

  • 資料夾內檔案名全複製
  • 資料夾內檔案名全複製
  • [快速]Visual Studio 快捷鍵列表
  • [快速]Visual Studio 快捷鍵列表
  • [ASP.Net]Eval和Bind之間的差異
  • [ASP.Net]Eval和Bind之間的差異
  • [JavaScript]執行前端程式時出現的錯誤:Unexpected end of input
  • [JavaScript]執行前端程式時出現的錯誤:Unexpected end of input
  • [C#]GridView隱藏欄位之二 RowCreated
  • [C#]GridView隱藏欄位之二 RowCreated

誰來我家

誰來我家

熱門文章

  • (35,251)[快速]Visual Studio 快捷鍵列表
  • (6,047)[JavaScript]執行前端程式時出現的錯誤:Unexpected end of input
  • (2,614)資料夾內檔案名全複製
  • (1,350)[C#]GridView隱藏欄位之一 OnRowDataBound
  • (1,202)[C#]GridView隱藏欄位之二 RowCreated

熱門文章

  • (35,251)[快速]Visual Studio 快捷鍵列表
  • (6,047)[JavaScript]執行前端程式時出現的錯誤:Unexpected end of input
  • (2,614)資料夾內檔案名全複製
  • (1,350)[C#]GridView隱藏欄位之一 OnRowDataBound
  • (1,202)[C#]GridView隱藏欄位之二 RowCreated

最新留言

    最新留言

      動態訂閱

      動態訂閱

      文章精選

      文章精選

      文章搜尋

      文章搜尋

      參觀人氣

      • 本日人氣:
      • 累積人氣:

      參觀人氣

      • 本日人氣:
      • 累積人氣:

      留言板

      留言板