GW知识点
2024-09-07 01:39:51
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;
}
}
}
最新文章
- Socket服务端和客户端(C++,CodeBlocks+GCC编译)
- lua弱表引用
- PHP正则表达式基础入门
- Maven-002-eclipse 插件安装及实例
- JavaWeb(一)
- Solr部署准备
- php操作xml并插入到数据库中
- jsonarray和jsonobject
- 浏览器中页面的visibility状态及变化监听
- mode
- java面试题,附个人理解答案
- SoapUI测试WebService接口
- Ubuntu16.04 apt源更新
- dubbo协议报文格式
- Vue+Webpack常见问题(持续更新)
- 【个人总结】软件工程M1/M2总结
- Dynamics CRM Solution
- Spring Security教程(七):RememberMe功能
- ucos串口通讯模块设计
- 使用spring cache和ehcache