各位高手帮帮忙...
GridView控件中如何绑定int类型值...
如果数据字段值为1的话,则在GridView控件的状态列中输出为首页显示,如果数据字段值为2的话,则在GridView的状态列中输出为审核通过.大家帮帮忙.....

解决方案 »

  1.   

    转成STRING   使用的时候 得到1这个字符串 然后转正int再判断就OK了
      

  2.   

    这个你可以在SQL处理撒
    select f1,f2,(case f3 when 1 then '首页显示' when 2 then '审核通过' end) as f3 from tab
      

  3.   

    给你写段代码你看看就会了<asp:BoundField DataField="要绑定的字段" HeaderText="控制" SortExpression="Auditing" />后台 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            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>";
                }
            }
          
        }
      

  4.   

    在GridView的RowDataBaind事件中写:
        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 ="审核通过";
                }
            }
        }
      

  5.   

    1.直接用查询语句写:
      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.列名"))) %>'
      

  6.   

    在绑定的时候按下面写就ok了,不用那么麻烦
    <%#Eval("列名").ToString()=="1"?"首页显示":"审核通过"%>
      

  7.   

    如果想在一列中绑定多个数据字段怎么绑定... 
    比如我想在状态例中绑定f1,f2这两个字段集.. 
    是怎么绑定的.
    用模板列
                              <asp:TemplateField HeaderText="负责人">
                              <ItemTemplate>
                               DataBinder.Eval(Container, "DataItem.f1") DataBinder.Eval(Container, "DataItem.f2")
                              </ItemTemplate>
                            </asp:TemplateField>
      

  8.   

    写个函数阿,
    <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;
        }
      

  9.   

    <%# Eval("shenhe").ToString() == "1" ? "已审核" : "<font color=red>未审核</font>"%>
      

  10.   

    我是想用在GridView控件里....
    楼上的几位大哥可能没有理解我的意思./.
      

  11.   

    这个就是在GridView的模板列中进行数据绑定的,没用其它的控件