ASP .NET RowUpdating GridView Troubles

后端 未结 3 921
-上瘾入骨i
-上瘾入骨i 2021-01-21 11:46

I\'m having trouble with the RowUpdating Method. My GridView is connected to our local SQL Server, and I\'m trying to update the data. Here is the cod

3条回答
  •  无人及你
    2021-01-21 12:25

    Not all GridViewRow have a DataItem.

    You should add a if block around your code and verify the row being updated is of type DataRow.

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
         your code here...
    }
    

    More regarding RowTypes : http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridviewrow.rowtype.aspx

提交回复
热议问题