无法更新列,具体取决于gridview中的其他列

问题描述

我有一个gridview,网格有5个不同的ID,FirstName,LastName,DateOfBirth和Age列,可以编辑gridview,所以我想根据DateOfBirth列更新Age,所以我在OnRowBound函数中编写了必要的功能。在网格视图页面上,我得到\“字符串未被识别为有效的日期时间\”。 这是OnRowBound的功能
 protected void UserInfoGrid_RowDataBound(object sender,GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DateTime DOBOnGrid = DateTime.ParseExact(e.Row.Cells[3].Text,\"MM/dd/yyyy\",null);
            Label tAge = (Label)e.Row.Cells[4].FindControl(\"txtAge\");

            TimeSpan ts = DateTime.Now - DOBOnGrid;
            int CurrAge = ts.Days / 365;
            tAge.Text = CurrAge.ToString();
        }
    }

  <asp:GridView ID=\"UserInfoGrid\" runat=\"server\" AutoGenerateColumns=\"False\" CellPadding=\"3\"
            DataKeyNames=\"userid\" DataSourceID=\"DataSrcUserInfo\"
            AllowPaging=\"True\" OnRowDataBound=\"UserInfoGrid_RowDataBound\"
            OnRowUpdated=\"Update\" OnRowDeleted=\"Delete\" PageSize=\"10\" >
谁能帮我这个 谢谢,     

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)