1、取值:

        protected void Button1_Click(object sender, EventArgs e)
{
string str = "";
foreach (GridViewRow row in this.GridView1.Rows)
{
str += ((Label)row.FindControl("Label2")).Text + ",";
str+= row.Cells[0].Text.ToString();
}
}

2、

<script runat="server">
void AuthorsGridView_SelectedIndexChanged(Object sender, EventArgs e) {
String lastName = selectRow.Cells[].Text; // 针对BoundField字段
DataBoundLiteralControl firstNameLiteral = (DataBoundLiteralControl)selectRow.Cells[].Controls[]; //针对TemplateField字段
String firstName = firstNameLiteral.Text;
}
</script>
<asp:gridview id="AuthorsGridView" datasourceid="AuthorsSqlDataSource"
autogeneratecolumns="false" autogenerateselectbutton="true"
onselectedindexchanged="AuthorsGridView_SelectedIndexChanged" runat="server">
<columns>
<asp:boundfield datafield="au_lname" headertext="Last Name"/>
<asp:templatefield headertext="FirstName">
<itemtemplate> <%#Eval("au_fname")%> </itemtemplate>
</asp:templatefield>
</columns>
</asp:gridview>

3、

        protected void GVListShow_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//加入超市
switch (e.Row.Cells[11].Text.Trim())
{
case "True":
e.Row.Cells[11].Text = "一口价";
e.Row.BackColor = System.Drawing.Color.PowderBlue;
break; default: e.Row.Cells[11].Text = "   议价"; break;
} //设为推荐
switch (e.Row.Cells[12].Text.Trim())
{
case "0":
break;
default: e.Row.BackColor = System.Drawing.Color.Wheat; ; break;
} switch (e.Row.Cells[1].Text.Trim())
{
case "0": e.Row.Cells[1].Text = "采购"; break;
case "1": e.Row.Cells[1].Text = "销售"; break;
case "2": e.Row.Cells[1].Text = "混合"; break;
default: e.Row.Cells[1].Text = "未知"; break;
} switch (e.Row.Cells[9].Text.Trim())
{
case "1": e.Row.Cells[9].Text = "过磅"; break;
case "2": e.Row.Cells[9].Text = "标重"; break;
case "3": e.Row.Cells[9].Text = "检尺"; break;
default: e.Row.Cells[9].Text = "未知"; break;
} //选择
DateTime oldTime = DateTime.Parse(e.Row.Cells[13].Text.Trim());//dt
DateTime queryTime = DateTime.Parse(DotNet.Common.Date.GetDateStr());
if (oldTime >= queryTime)
{
CheckBox ck = (CheckBox)e.Row.FindControl("chkSelect");
if (ck != null)
{
ck.Checked = true;
}
} //处理价格
if (decimal.Parse(e.Row.Cells[8].Text.Trim()) <= 0)
{
if (e.Row != null) e.Row.Cells[8].Text = "电议";
//case "2": e.Row.Cells[5].Text = "标重"; break;
}
}
}

最新文章

  1. Socket服务端和客户端(C++,CodeBlocks+GCC编译)
  2. lua弱表引用
  3. PHP正则表达式基础入门
  4. Maven-002-eclipse 插件安装及实例
  5. JavaWeb(一)
  6. Solr部署准备
  7. php操作xml并插入到数据库中
  8. jsonarray和jsonobject
  9. 浏览器中页面的visibility状态及变化监听
  10. mode
  11. java面试题,附个人理解答案
  12. SoapUI测试WebService接口
  13. Ubuntu16.04 apt源更新
  14. dubbo协议报文格式
  15. Vue+Webpack常见问题(持续更新)
  16. 【个人总结】软件工程M1/M2总结
  17. Dynamics CRM Solution
  18. Spring Security教程(七):RememberMe功能
  19. ucos串口通讯模块设计
  20. 使用spring cache和ehcache

热门文章

  1. Apache + Tomcat集群 + 负载均衡
  2. 第三篇: Ansible 配置节点认证
  3. 04 Memcached过期机制与删除机制
  4. PHP-Manual的学习----【入门指引】
  5. 【BZOJ3112】[Zjoi2013]防守战线 单纯形法
  6. F - Monkey Banana Problem
  7. WebApi 中使用 Session
  8. rm_invalid_file
  9. 类加载(一):static块 和 Class.forName
  10. Jquery遍历table并拿到每个单元格里的值