各位高手帮帮忙...
GridView控件中如何绑定int类型值...
如果数据字段值为1的话,则在GridView控件的状态列中输出为首页显示,如果数据字段值为2的话,则在GridView的状态列中输出为审核通过.大家帮帮忙.....
GridView控件中如何绑定int类型值...
如果数据字段值为1的话,则在GridView控件的状态列中输出为首页显示,如果数据字段值为2的话,则在GridView的状态列中输出为审核通过.大家帮帮忙.....
select f1,f2,(case f3 when 1 then '首页显示' when 2 then '审核通过' end) as f3 from tab
{
if (e.Row.RowType == DataControlRowType.DataRow)
{ if (e.Row.Cells[3].Text == "1")
{ e.Row.Cells[3].Text = "首页显示";
}
else
{ e.Row.Cells[3].Text = "<font color=red>已审核</font>";
}
}
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
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 ="审核通过";
}
}
}
case 列名 when 1 then '首页显示' when 2 then '审核通过' end as 列名2.写个方法。
后台:public string GetProgramlist(int status)
{
if (status==1)
return "首页显示";
else
return "审核通过";
}前台:Text='<%# GetProgramlist(Convert.ToBoolean(DataBinder.Eval(Container, "DataItem.列名"))) %>'
<%#Eval("列名").ToString()=="1"?"首页显示":"审核通过"%>
比如我想在状态例中绑定f1,f2这两个字段集..
是怎么绑定的.
用模板列
<asp:TemplateField HeaderText="负责人">
<ItemTemplate>
DataBinder.Eval(Container, "DataItem.f1") DataBinder.Eval(Container, "DataItem.f2")
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField SortExpression="CheckProcessWaterAmountPrev">
<HeaderTemplate>
<asp:Label ID="lblTest1" runat="server" Text="Name"></asp:Label>
</HeaderTemplate>
<ItemTemplate>
<asp:Label ID="lblTest2" runat="server" Text='<%# GetName((int)(Eval("FieldName"))) %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>public string GetName(int value)
{
string result = "";
if( value == 1)
{
result = "首页显示";}
else if( value == 2)
{
result = "审核通过";}
return result;
}
楼上的几位大哥可能没有理解我的意思./.