在gridview中的数据绑定期间修改数据源行值

Mic*_*per 2 .net c# asp.net gridview

我有一个网格视图,我绑定数据表.我的问题是数据表有整数值因为1,2,3,4,5.我希望A,B,C,D,E在网格视图中分别绑定所有这些值.我正在使用绑定字段.我不知道在哪里修改来自数据表的数据?

Muh*_*tar 5

将该列设置为"模板"列并放置标签

<asp:TemplateField HeaderText="HeaderText">
 <ItemTemplate>
 <asp:Label ID="lbl" runat="server" ></asp:Label>
</ItemTemplate>
Run Code Online (Sandbox Code Playgroud)

然后你在RowDataBoundGridview的情况下这样做

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
    DataRow dr = ((DataRowView)e.Row.DataItem).Row;
    if(dr["ColumnName"].ToString() == "1" )
    {
      ((Label)e.Row.FindControl("lbl")).Text = "A";
    }
    else if(dr["ColumnName"].ToString() == "2" )
    {
      ((Label)e.Row.FindControl("lbl")).Text = "B";
    }
     ................
      ................
   }
}
Run Code Online (Sandbox Code Playgroud)