This is a migrated thread and some comments may be shown as answers.

[Solved] Change the value of a data cell

1 Answer 142 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 30 Jul 2009, 10:37 PM
I know this is really basic coding, have searched around here cannot find an answer... I need to change the value of a data cell if a condition is met, the column is say InvoiceStatusID, say it has a value of "O" if that condition is met I just need to change the output to "Invoice" the code I have tried obviously doesn't work and I'm new to ASP.NET.
    Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated 
        Dim dataItem As GridDataItem = Nothing 
        Dim data As Data.DataRowView = Nothing 
        Try 
 
            If TypeOf e.Item Is GridDataItem Then 
 
                dataItem = CType(e.Item, GridDataItem) 
                data = CType(dataItem.DataItem, Data.DataRowView) 
 
 
                If CType(data.Row.Item("InvoiceStatusID"), String) = "O" Then 
                    CType(data.Row.Item("InvoiceStatusID"), TextBox).Text = "Invoice" 
                Else 
                    CType(data.Row.Item("InvoiceStatusID"), TextBox).Text = "Closed" 
                End If 
 
            End If 
        Catch ex As Exception 
 
        Finally 
 
            dataItem = Nothing 
            data = Nothing 
        End Try 
    End Sub 
.. be kind lol, here is what doesn't work:

1 Answer, 1 is accepted

Sort by
0
Mark
Top achievements
Rank 1
answered on 31 Jul 2009, 12:06 AM
I ended up piecing this together myself... May help someone too, so i've pasted the code below:
            If TypeOf e.Item Is GridDataItem Then 
                Dim item As GridDataItem = DirectCast(e.Item, GridDataItem) 
                If item("InvoiceStatusID").Text = "O" Then 
                    item("InvoiceStatusID").Text = "Invoice" 
                Else 
                    item("InvoiceStatusID").Text = "Closed" 
                End If 
            End If 

Tags
Grid
Asked by
Mark
Top achievements
Rank 1
Answers by
Mark
Top achievements
Rank 1
Share this question
or