从数据库中检索了一组数据表后,我需要在绑定到gridview之前编辑行值.例如,从数据库中检索一组数据表.
例如:[userid],[userEmail] - > 1,james @ hotmail.com
我想将"james@hotmail.com"更改为"james",然后将其绑定到gridview.[userEmail]的每一行都将与邮件扩展名(@ hotmail.com)分开......我该怎么做..?
这样的事情应该有效:
DataTable dt = getMyDataTable(); foreach (DataRow dr in dt.Rows) { string email = Convert.ToString(dr["email"]); email = email.Substring(0, email.IndexOf('@')); dr["email"] = email; }