Results 1 to 7 of 7

Thread: Adding textbox to gridview

  1. #1
    Junior Member
    Join Date
    Aug 08
    Posts
    25

    Adding textbox to gridview

    My problem is that I have a gridview with five rows and an unknow number of columns. What I want to do is in row 1 I want each column to be a textbox and in the next row create a button/link to create a report for each column. My problem is only the last column is being changed to a textbox. Here is my code.

    HTML Code:
    Protected Sub gvReport_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvReport.RowDataBound
    
    Dim link() As String
    
    Dim tb8 As New WebControls.TextBox
    
    If e.Row.RowType = DataControlRowType.DataRow Then
    
    If e.Row.RowIndex = 1 Then
    
    ' Display the company name in italics.
    
    For i As Integer = 1 To e.Row.Cells.Count - 2
    
    tb8.Width = 30
    
    tb8.Font.Size = 12
    
    tb8.Font.Name = "Times Roman"
    
    tb8.Text = e.Row.Cells(i).Text
    
    e.Row.Cells(i).Controls.Add(tb8)
    
    Next
    
    End If
    
    ReDim link(e.Row.Cells.Count - 1)
    
    If e.Row.RowIndex = 2 Then
    
    For i As Integer = 1 To e.Row.Cells.Count - 1
    
    If e.Row.Cells(i).Text <> "N/A" Then
    
    e.Row.Cells(i).Text = "<u>" & e.Row.Cells(i).Text & "</u>"
    
    ' e.Row.Cells(i).Text = "<a href='mailto:" & e.Row.Cells(i).Text & "'>" & e.Row.Cells(i).Text & "</a>"
    
    link(i) = e.Row.Cells(i).Text
    
    End If
    
    Next
    
    End If
    
    End If
    
    End Sub

  2. #2
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,744

    Re: Adding textbox to gridview

    Mrrenzo0861,

    I am going to assume that you are using ASP.Net and move your question to the ASP.Net forum. If this is not the case, then let me know.

    Gary

  3. #3
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,744

    Re: Adding textbox to gridview

    Hello Mrrenzo0861,

    In order to best help you we are going to need to fully understand what you are trying to achieve. Is it possible that you can create a mockup of exactly what you want?

    Thanks

    Gary

  4. #4
    Junior Member
    Join Date
    Aug 08
    Posts
    25

    Re: Adding textbox to gridview

    What is happening is the user puts in the search criteria. And depending on the information put in the app creates a gridview of the data with 5 rows and a various number of columns. The first row should be all textboxes and the second row should be a link to run a report. And yes asp.net is the front end.

  5. #5
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,744

    Re: Adding textbox to gridview

    Hello,

    Did you see my question about creating a mock up? From the description that you have provided, it is quite difficult to visualise the requirement.

    Gary

  6. #6
    Junior Member
    Join Date
    Aug 08
    Posts
    25

    Thumbs up Re: Adding textbox to gridview

    I solved my problem while trying to solve a different issue. I was missing this statement in my .aspx file.
    OnRowDataBound="gvReport_RowDataBound"

  7. #7
    ASP.NET Moderator gep13's Avatar
    Join Date
    Nov 04
    Location
    The Granite City
    Posts
    21,744

    Re: Adding textbox to gridview

    Hello,

    Glad to hear that you got it sorted!!

    If your question has been answered/resolved, can you please remember to mark your thread as resolved?

    Thanks

    Gary

Posting Permissions

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