Results 1 to 7 of 7

Thread: [2005] parse a column in gridview

  1. #1

    Thread Starter
    Member computerguy46's Avatar
    Join Date
    Jan 2006
    Posts
    32

    Talking [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

  2. #2
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    Re: [2005] parse a column in gridview

    did you call GridView1.Databind() after this?Also RowDataBound will be the best place to this operation.
    __________________
    Rate the posts that helped you

  3. #3

    Thread Starter
    Member computerguy46's Avatar
    Join Date
    Jan 2006
    Posts
    32

    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

  4. #4

    Thread Starter
    Member computerguy46's Avatar
    Join Date
    Jan 2006
    Posts
    32

    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

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] parse a column in gridview

    Is it a TemplateField?

  6. #6

    Thread Starter
    Member computerguy46's Avatar
    Join Date
    Jan 2006
    Posts
    32

    Re: [2005] parse a column in gridview

    no it is a boundfield

  7. #7
    Frenzied Member
    Join Date
    Jan 2006
    Posts
    1,875

    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
    __________________
    Rate the posts that helped you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width