GRIDVIEW动态显示问题 在线等 谢谢 GRIDVIEW中有个绑定列 数据库中字段值 为1,2,3等 想实现效果为 当为1时,GRIDVIEW中显示 "处理" 当为2时,GRIDVIEW中显示 "处理中"谢谢 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你的datasource是怎么取的如果是sql的话,直接case when就可以了 同意楼上,或者RowDataBound中处理 同意楼上,可以在RowDataBound中处理,也可以将所有数据放到一个dataset里面处理数据后和GRIDVIEW绑定 能给出代码吗? protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (GridView1.Rows[e.Row.RowIndex].Cells[5].Text.ToString()=="1") { } }其中的代码不会写 给GridView添加RowDataBound消息if(e.Row.RowType == DataControlRowType.DataRow){ if(e.Row.Cells[...].Text == "1") { e.Row.Cells[...].Text = "处理"; } else if(e.Row.Cells[...].Text == "2") { e.Row.Cells[...].Text = "处理中"; }} 代码应该没问题 if(e.Row.RowType == DataControlRowType.DataRow){ if(e.Row.Cells[...].Text == "1") { e.Row.Cells[...].Text = "处理"; } else if(e.Row.Cells[...].Text == "2") { e.Row.Cells[...].Text = "处理中"; }} 可是还是不行 我晕 protected void GVRc_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[9].Text.Trim() == "禁用") { e.Row.Cells[9].Text = "点击启用"; } else if (e.Row.Cells[9].Text.Trim() == "启用") { e.Row.Cells[9].Text = "点击禁用"; } }} 那就放到dataset里面 for(int i=0;i<ds.Table[0].Rows.Count;i++){ if(ds.Tables[0].Rows[i]["字段"].ToString().Trim()=="1") { ds.Tables[0].Rows[i]["字段"] = "处理"; }};然后在 GRIDVIEW.DataSourse = ds.Tables[0];有小问题自己改下... 我晕这个事件没有执行protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { Response.Write("fdslkfs"); if (e.Row.RowType == DataControlRowType.DataRow) { if (e.Row.Cells[6].Text.Trim() == "处理") { e.Row.Cells[6].Text = "gaibain"; } else if (e.Row.Cells[6].Text.Trim() == "处理中") { e.Row.Cells[6].Text = "hehe"; } } } Response.Write("fdslkfs");这个都没打出来 想问下楼主,GridView的数据是不是绑定的? 一种方法是 在数据源(dataset或者datatable)中新加入一列,循环一下判断=1 新列的该行插入“处理” =2 插入“处理中”一种方法是 在html里绑定字段时<%#ChangeChineseState(DataBinder.Eval(Container.DataItem,"字段名"))%>CS添加方法public string ChangeChineseState(object _state){ if (_state.ToString() == "1") return "处理"; if (_state.ToString() == "2") return "处理中";}一种方法是 在数据绑定时的事件里判断像dingyong7643099() 的做法 郁闷,IIS不能用!!!! vb.net web软件开发 如何生成pdf文档? 套用了母版页的页面怎么局部刷新内容页? 急问有关cab显示在网页的问题? gridview中移动到下一条记录的代码是什么? 如何在后台实现脚本隐藏DATAGRID的某一列标题 虚拟主机上怎么建目录 关于传输数据大小,设置webconfig的问题? 请问如何修改Discuz!NT论坛的“注册”? 怎么是窗口最大化啊 ? 请高手们帮帮忙!!在.net中怎么生成像excel当中的图表 心情好,呵呵,请问是Cache可以被所有人访问,还是ViewState可能被所有人访问??{100分,100分,开心散分!!}
如果是sql的话,直接case when就可以了
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) {
if (GridView1.Rows[e.Row.RowIndex].Cells[5].Text.ToString()=="1")
{
}
}其中的代码不会写
if(e.Row.RowType == DataControlRowType.DataRow)
{
if(e.Row.Cells[...].Text == "1")
{
e.Row.Cells[...].Text = "处理";
}
else if(e.Row.Cells[...].Text == "2")
{
e.Row.Cells[...].Text = "处理中";
}
}
{
if(e.Row.Cells[...].Text == "1")
{
e.Row.Cells[...].Text = "处理";
}
else if(e.Row.Cells[...].Text == "2")
{
e.Row.Cells[...].Text = "处理中";
}
}
可是还是不行 我晕
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[9].Text.Trim() == "禁用")
{
e.Row.Cells[9].Text = "点击启用";
}
else if (e.Row.Cells[9].Text.Trim() == "启用")
{
e.Row.Cells[9].Text = "点击禁用";
}
}
}
for(int i=0;i<ds.Table[0].Rows.Count;i++)
{
if(ds.Tables[0].Rows[i]["字段"].ToString().Trim()=="1")
{
ds.Tables[0].Rows[i]["字段"] = "处理";
}
};
然后在 GRIDVIEW.DataSourse = ds.Tables[0];有小问题自己改下...
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
Response.Write("fdslkfs");
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.Cells[6].Text.Trim() == "处理")
{
e.Row.Cells[6].Text = "gaibain";
}
else if (e.Row.Cells[6].Text.Trim() == "处理中")
{
e.Row.Cells[6].Text = "hehe";
}
} }
Response.Write("fdslkfs");
这个都没打出来
CS添加方法
public string ChangeChineseState(object _state)
{
if (_state.ToString() == "1")
return "处理";
if (_state.ToString() == "2")
return "处理中";
}一种方法是 在数据绑定时的事件里判断
像dingyong7643099() 的做法