GridView数据替换,数字按要求替换文字

可以在GrivdView的行绑定(RowDataBound)事件中改写
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string i = e.Row.Cells[1].Text; //Cells[I]表示列的索引,从0开始
if (i == "1")
{
e.Row.Cells[1].Text = "男";
}
else
{
e.Row.Cells[1].Text = "女";
}
}
}
转自百度知道回答
原文地址:https://www.cnblogs.com/liziqiang/p/3396895.html