Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
How to Set a cell Value in a New Row
posted

Hi,

I cannot figure out how to set the value of a specific cell in a new row to the value of a variable.  Any ideas?  Thanks!  Here's the code I have:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Protected Sub btnAddParent_Click(ByVal sender As System.Object, ByVal e As  System.Web.UI.ImageClickEventArgs)

 

 

Dim BusinessName As String

 

 

'Set the variable to the value of the first row, first column:
BusinessName = grdDetail.DisplayLayout.Rows(0).Cells(1).Value

hfCellToFocus.Value = 1

grdDetail.Rows.FromKey(0).Cells(1).Text = BusinessName 'THIS DOESN'T WORK, I get a message that says "Object reference not set to an instance of an object".

 

 

End Sub

Parents
  • 14517
    Offline posted

    Hello,

    Your best option is to use the FromDataKey method or the index of the rows collection to find the row to update.

    Please let me know if you have any questions.

    Thanks,

    Valerie

     

     

Reply Children