佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > dataGrid 多維表頭、表頭跨行跨列設(shè)計及綁定數(shù)據(jù)

dataGrid 多維表頭、表頭跨行跨列設(shè)計及綁定數(shù)據(jù)

熱門標(biāo)簽:阿里云 銀行業(yè)務(wù) 科大訊飛語音識別系統(tǒng) 電子圍欄 Linux服務(wù)器 Mysql連接數(shù)設(shè)置 服務(wù)器配置 團購網(wǎng)站
dataGrid 其實就是一個html table 
想清楚這個以后,要設(shè)置多維表頭就好辦了
html代碼
復(fù)制代碼 代碼如下:

asp:DataGrid ID="DataGrid1" runat="server"
onitemdatabound="DataGrid1_ItemDataBound">
/asp:DataGrid>

然后綁定數(shù)據(jù)
復(fù)制代碼 代碼如下:

protected void Page_Load(object sender, EventArgs e)
{
string strsql = "select EmpID, Name, BranchID, LoginID, Pwd, Sex, EmpCode, Email, OfficeTel from mrBaseInf";
SqlConnection con = new SqlConnection("server=.;database=iOffice2009;uid=sa;pwd=sa");
DataSet ds = new DataSet();
SqlDataAdapter ter = new SqlDataAdapter(strsql, con);
con.Open();
ter.Fill(ds);
con.Close();
this.DataGrid1.DataSource = ds;
DataGrid1.DataBind();
}

接下來添加DataGrid1_ItemDataBoun事件
復(fù)制代碼 代碼如下:

protected void DataGrid1_ItemDataBound(object sender, DataGridItemEventArgs e)
{
if (e.Item.ItemType==ListItemType.Header)
{
e.Item.Cells[0].RowSpan = 2;
e.Item.Cells[1].RowSpan = 2;
e.Item.Cells[2].RowSpan = 2;
e.Item.Cells[3].RowSpan = 2;
e.Item.Cells[4].RowSpan = 2;
e.Item.Cells[5].ColumnSpan = 4;
e.Item.Cells[5].HorizontalAlign = HorizontalAlign.Center;
e.Item.Cells[5].Text = "測試/td>/tr>tr>td>列1/td>td>列2/td>td>列3/td>td>列4/td>/tr>";
e.Item.Cells[6].Visible = false;
e.Item.Cells[7].Visible = false;
e.Item.Cells[8].Visible = false;
}
}

效果圖
您可能感興趣的文章:
  • asp.net DataGrid 中文字符排序的實現(xiàn)代碼
  • DataGrid 動態(tài)添加模板列 實現(xiàn)代碼
  • asp.net DataGrid控件中彈出詳細(xì)信息窗口
  • 如何在DataGrid控件中實現(xiàn)自定義分頁
  • ASP.NET中為DataGrid添加合計字段
  • DataGrid使用心得(調(diào)用及連接數(shù)據(jù)庫等等)

標(biāo)簽:廣元 蚌埠 衡水 江蘇 棗莊 大理 衢州 萍鄉(xiāng)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《dataGrid 多維表頭、表頭跨行跨列設(shè)計及綁定數(shù)據(jù)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    新乐市| 黑山县| 中方县| 梅河口市| 东兰县| 桂东县| 闸北区| 望都县| 贵州省| 屏东县| 崇阳县| 高邮市| 崇信县| 扎兰屯市| 镇巴县| 泗洪县| 金坛市| 扶绥县| 宜州市| 盐源县| 绥阳县| 蒙自县| 田阳县| 云安县| 桐乡市| 鞍山市| 开鲁县| 黔南| 新安县| 华池县| 运城市| 元谋县| 岳池县| 丰县| 阜城县| 潜江市| 延吉市| 雅江县| 威宁| 新绛县| 瓦房店市|