[2005] parse a column in gridview
when the data goes to gridview i am trying to change how the data is displayed in the third column. so far i can get the data formated as i want in
textbox5.text the porblem is getting it back in to gridview column 3 on all rows.
Dim i As Integer
Do While dr.Read()
Dim str As String
TextBox4.Text = dr.Item("cardnum").ToString()
str = TextBox4.Text
TextBox5.Text = "************" & str.Substring(12, 4)
GridView1.Rows(i).Cells(2).Text = TextBox5.Text
Loop
thanks in advance
Re: [2005] parse a column in gridview
did you call GridView1.Databind() after this?Also RowDataBound will be the best place to this operation.
Re: [2005] parse a column in gridview
i have tryed these 3 ways to parse the data
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
'If e.Row.RowType = DataControlRowType.DataRow Then
' Dim str As String = e.Row.Cells(2).Text.Trim()
' e.Row.Cells(2).Text = str.Substring(str.Length - 4, 4)
'Else
' Dim str1 As String = e.Row.Cells(2).Text.Trim()
' e.Row.Cells(2).Text = str1.Remove(0, str1.Length - 4)
'End If
If e.Row.RowType = DataControlRowType.DataRow Then
Dim str2 As String = e.Row.Cells(2).Text.Trim()
e.Row.Cells(2).Text = str2.Substring(12, 4)
End If
End Sub
Re: [2005] parse a column in gridview
sorry tryed to press the space bar is somehow posted
the 3 i have posted do not work they do not change the data at all
on GridView1.Rows(i).Cells(2).Text = TextBox5.Text
textbox5 has the data correct but the gridview 1 does not display any data at all
Re: [2005] parse a column in gridview
Re: [2005] parse a column in gridview
Re: [2005] parse a column in gridview
wondering if cell(2) is the column you want to edit and it's Visible?
if thats the case just see if this works
Code:
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Cells(2).Text = "abcd"
End If
End Sub