我想在 gridview 中隐藏手机号码的最后 4 位数字并将最后 4 位数字显示为 **** 。我只得到标题值而不是项目模板值。如何获取移动值/项目值并对其进行编辑并分配到 GridView ?
protected void gvrequests_RowDataBound(object sender, GridViewRowEventArgs e)
{
string Mobile = e.Row.Cells[3].Text;
string securedPhone = Mobile .Remove(6);
string MobileSecured= securedPhone + "****";
e.Row.Cells[3].Text=MobileSecured
}
最佳答案
您需要首先检查该行是否是 DataRow。
protected void gvrequests_RowDataBound(Object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// your logic will go here
}
}
关于c# - 如何更改行数据绑定(bind)事件中gridview的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32344839/