WebDataGrid Cell Value

Answered (Verified) This post has 1 verified answer | 2 Replies | 2 Followers Thread's RSS feed.

ngrs01
Points 90
Replied On: Thu, May 24 2012 10:56 PM Reply

I am trying to retreive the value of a cell from a selected row in a  webdata grid when I click a command button

Here is the code I have in the command button

 

 

 

 

 

 

 

 

 

 

 

Protected Sub Button_Edit_Click(sender As Object, e As EventArgs) Handles Button_Edit.Click

 

 

 

Dim SelComment As String

 

 

 

Dim cIndex As Integer

 

 

 

Dim selectedRow As Integer

 

 

 

If GridView.Behaviors.Selection.SelectedRows.Count > 0 Then

 

 

 

    SelComment = GridView.Behaviors.Selection.SelectedRows(0).DataItem (0).ToString

 

 

End Sub

When I click on the button, I always get this error:

System.NullReferenceException

Why am I getting null values from the grid, when I have a selected row?

I am not able to get any of the cell values from the selected row.

A related problem is when the button does the post back, all the rows on the grid disppears. Not sure why.

I am using Visual Studio 2010 and the version of NetAdvantage I have is

Version=11.2.20112.1019

Please help.

Thanks

  • Post Points: 20

Verified Answer

Answered (Verified) Replied On: Fri, May 25 2012 4:00 PM Reply
Verified by ngrs01

Hello ngrs01,

I have created a sample to demonstrate how you can achieve this. Instead of going through the DataItem you will want to go through the Items to get a cell value. Also I believe this and the other issue you are experiencing of the grid disappears is a result of you not setting the data back to the grid on postback. The sample I have attached demonstrates this.

Please let me know if you have any questions concerning this matter.

Sincerely,
Mike P.
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com

  • Post Points: 40

All Replies

Answered (Verified) Replied On: Fri, May 25 2012 4:00 PM Reply
Verified by ngrs01

Hello ngrs01,

I have created a sample to demonstrate how you can achieve this. Instead of going through the DataItem you will want to go through the Items to get a cell value. Also I believe this and the other issue you are experiencing of the grid disappears is a result of you not setting the data back to the grid on postback. The sample I have attached demonstrates this.

Please let me know if you have any questions concerning this matter.

Sincerely,
Mike P.
Developer Support Engineer
Infragistics, Inc.
www.infragistics.com

  • Post Points: 40
ngrs01
Points 90
Replied On: Tue, May 29 2012 10:44 PM Reply

Thanks Mike, I got the grid working the way you suggested. I am able to get to the cell value as I could with the UltraGrid. Thanks again.

  • Post Points: 5
Page 1 of 1 (3 items) | RSS