我绑定的DataField="ProductType",希望根据数据的值来,转换形式.如:ProductType=1就显示:高级
ProductType=2就显示:中级
大概就是这个意思,但不知道怎么格式化。      <asp:GridView ID="GridViewCustomerList">
<Columns>
     <asp:BoundField DataField="ProductType" HeaderText="产品类型" />
</Columns>
        </asp:GridView>

解决方案 »

  1.   

    再datarowbound事件里面自己处理一下
      

  2.   

    在属性-事件-添加rowdatabinded事件
      

  3.   

    比如:
    protected void GridView1_DataBound(object sender, EventArgs e)
            {
                foreach (GridViewRow row in this.GridView1.Rows)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        string text = row.Cells[3].Text;//cell的索引值
                        switch (row.Cells[3].Text)
                        {
                            case "1":
                                row.Cells[3].Text = "高级 ";
                           
                                break;
                            case "2":
                                row.Cells[3].Text = "中级";
                                break;
                        }                }
                }
            }
      

  4.   

      <asp:GridView ID="GridViewCustomerList">
    <Columns>
         <asp:BoundField DataField='<%# ChangeType(Eval("ProductType").ToString())%>' HeaderText="产品类型" />
    </Columns>
            </asp:GridView>
    cs文件public string ChangeType(string type)
    {
       if(type=="1")
            ...
    }
      

  5.   

                    <asp:TemplateField HeaderText="产品类型">                    <ItemTemplate>                        <%# Eval("ProductType").ToString()=="1"?"高级":"中级"%>                    </ItemTemplate>                </asp:TemplateField>
      

  6.   

    主要 是这句
     <%# Eval("ProductType").ToString()=="1"?"高级":"中级"%>如果你的判断多的话那就在后台进行数据绑定的时候判断吧