gridview行绑定的简单运用

 1         /// <summary>
 2         /// GridView行绑定
 3         /// </summary>
 4         /// <param name="sender"></param>
 5         /// <param name="e"></param>
 6         protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
 7         {
 8             if (e.Row.RowType == DataControlRowType.DataRow)
 9             {
10                 if (objlist != null)
11                 {
12 
13                 }
14                 GridViewCommon.SetDeleteMsg(e);
15                 GridViewCommon.SetEditUrl(e, GridView1, 0);//默认第一列为查看,若第一列visable=false则不显示
16                 GridViewCommon.SetRowDataBound(sender, e, "编辑,删除");
17                 GridViewCommon.SetMouseColor(e);
18                 //e.Row.RowIndex;
19                 e.Row.Cells[1].Text = "<a href=\"#\" onclick=\"WinOpenEdit('" + GridView1.DataKeys[e.Row.RowIndex].Value.ToString() + "','view')\">" + e.Row.Cells[1].Text + "</a>";
20                 if (!string.IsNullOrEmpty(objlist.Rows[e.Row.RowIndex]["weeksummary"].ToString().Trim()))
21                 {
22                     e.Row.Cells[1].Text += "</br > <span style='color:Red'>本周总结:</span>" + objlist.Rows[e.Row.RowIndex]["weeksummary"].ToString();
23                 }
24                 if (!string.IsNullOrEmpty(objlist.Rows[e.Row.RowIndex]["weekplan"].ToString().Trim()))
25                 {
26                     e.Row.Cells[1].Text += "</br > <span style='color:Red'>本周计划:</span>" + objlist.Rows[e.Row.RowIndex]["weekplan"].ToString();
27                 }
28                 if (!string.IsNullOrEmpty(objlist.Rows[e.Row.RowIndex]["monthsummary"].ToString().Trim()))
29                 {
30                     e.Row.Cells[1].Text += "</br > <span style='color:Red'>本月总结:</span>" + objlist.Rows[e.Row.RowIndex]["monthsummary"].ToString();
31                 }
32                 if (!string.IsNullOrEmpty(objlist.Rows[e.Row.RowIndex]["monthplan"].ToString().Trim()))
33                 {
34                     e.Row.Cells[1].Text += "</br > <span style='color:Red'>本月计划:</span>" + objlist.Rows[e.Row.RowIndex]["monthplan"].ToString();
35                 }
36             }
37         }

原文地址:https://www.cnblogs.com/suwh/p/2551933.html