Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. I have to make a gridview which has the posibility of dinamically adding new rows and then to save it.

I have to make a gridview which has the posibility of dinamically adding new rows and then to save it.

Scheduled Pinned Locked Moved ASP.NET
help
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Member 4659001
    wrote on last edited by
    #1

    I have to make a gridview which has the posibility of dinamically adding new rows . In a first instance i made a gridview with an empty row, but i have to create more rows when the user fill all the cells of the row and press the tab key.and once i would be able to make it how i willbe able to save the data what i filled manually it is urgent Please help me

    Raghvendra

    C 1 Reply Last reply
    0
    • M Member 4659001

      I have to make a gridview which has the posibility of dinamically adding new rows . In a first instance i made a gridview with an empty row, but i have to create more rows when the user fill all the cells of the row and press the tab key.and once i would be able to make it how i willbe able to save the data what i filled manually it is urgent Please help me

      Raghvendra

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Member 4659001 wrote:

      it is urgent

      Of COURSE it is. Because your rentacoder deadline is tonight, right ? You'd use AJAX to do this, and javascript to insert the new row and to send the data back to the server to save it. There's probably a control in the ASP.NET AJAX library that does it already.

      Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

      M 2 Replies Last reply
      0
      • C Christian Graus

        Member 4659001 wrote:

        it is urgent

        Of COURSE it is. Because your rentacoder deadline is tonight, right ? You'd use AJAX to do this, and javascript to insert the new row and to send the data back to the server to save it. There's probably a control in the ASP.NET AJAX library that does it already.

        Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

        M Offline
        M Offline
        Member 4659001
        wrote on last edited by
        #3

        i have addeded new row but it does not seems so satisfactory(as my requirement is) but bcos as code for generating the new row is in Prerender event so when u fill the record and click to addnew row button . then bcos of postback all created row gone and so i dont find myself be able to prevent this code is Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender Dim GV As GridView = CType(sender, GridView) Dim intr As Integer = GV.Controls.Count Dim Tbl As Table = CType(GV.Controls(0), Table) Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) 'Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) If a = True Then Dim i As Integer For i = 0 To count Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) ' Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) Next End If End Sub Function AddEmptyRow() As GridViewRow Dim GVR As GridViewRow = New GridViewRow(GridView1.Rows.Count, 0, DataControlRowType.EmptyDataRow, DataControlRowState.Insert) Dim myTableCell As TableCell = New TableCell For i As Integer = 1 To 3 Dim myHyperLink As TextBox myHyperLink = New TextBox() myHyperLink.Width = New Unit(225) myTableCell.BorderStyle = BorderStyle.Solid myTableCell.BorderWidth = New Unit(1) myTableCell.Width = New Unit(700) myTableCell.BorderColor = Drawing.Color.Black myTableCell.BackColor = Drawing.Color.MistyRose myTableCell.Style.Add("text-align", "center") myTableCell.Controls.Add(myHyperLink) GVR.Cells.Add(myTableCell) Next Return GVR End Function Protected Sub b1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b1.Click count = count + 1 Dim grsidview As Table = CType(GridView1.FindControl("Tbl"), Table) GridView1.DataBind() a = True End Sub

        Raghvendra

        1 Reply Last reply
        0
        • C Christian Graus

          Member 4659001 wrote:

          it is urgent

          Of COURSE it is. Because your rentacoder deadline is tonight, right ? You'd use AJAX to do this, and javascript to insert the new row and to send the data back to the server to save it. There's probably a control in the ASP.NET AJAX library that does it already.

          Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

          M Offline
          M Offline
          Member 4659001
          wrote on last edited by
          #4

          First of all i say thanks to u i have addeded new row but it does not seems so satisfactory(as my requirement is) but bcos as code for generating the new row is in Prerender event so when u fill the record and click to addnew row button . then bcos of postback all created row gone and so i dont find myself be able to prevent this code is Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender Dim GV As GridView = CType(sender, GridView) Dim intr As Integer = GV.Controls.Count Dim Tbl As Table = CType(GV.Controls(0), Table) Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) 'Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) If a = True Then Dim i As Integer For i = 0 To count Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) ' Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) Next End If End Sub Function AddEmptyRow() As GridViewRow Dim GVR As GridViewRow = New GridViewRow(GridView1.Rows.Count, 0, DataControlRowType.EmptyDataRow, DataControlRowState.Insert) Dim myTableCell As TableCell = New TableCell For i As Integer = 1 To 3 Dim myHyperLink As TextBox myHyperLink = New TextBox() myHyperLink.Width = New Unit(225) myTableCell.BorderStyle = BorderStyle.Solid myTableCell.BorderWidth = New Unit(1) myTableCell.Width = New Unit(700) myTableCell.BorderColor = Drawing.Color.Black myTableCell.BackColor = Drawing.Color.MistyRose myTableCell.Style.Add("text-align", "center") myTableCell.Controls.Add(myHyperLink) GVR.Cells.Add(myTableCell) Next Return GVR End Function Protected Sub b1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b1.Click count = count + 1 Dim grsidview As Table = CType(GridView1.FindControl("Tbl"), Table) GridView1.DataBind() a = True End Sub

          Raghvendra

          C 1 Reply Last reply
          0
          • M Member 4659001

            First of all i say thanks to u i have addeded new row but it does not seems so satisfactory(as my requirement is) but bcos as code for generating the new row is in Prerender event so when u fill the record and click to addnew row button . then bcos of postback all created row gone and so i dont find myself be able to prevent this code is Protected Sub GridView1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.PreRender Dim GV As GridView = CType(sender, GridView) Dim intr As Integer = GV.Controls.Count Dim Tbl As Table = CType(GV.Controls(0), Table) Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) 'Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) If a = True Then Dim i As Integer For i = 0 To count Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) ' Tbl.Controls.AddAt(GV.Controls(0).Controls.Count, AddEmptyRow) Next End If End Sub Function AddEmptyRow() As GridViewRow Dim GVR As GridViewRow = New GridViewRow(GridView1.Rows.Count, 0, DataControlRowType.EmptyDataRow, DataControlRowState.Insert) Dim myTableCell As TableCell = New TableCell For i As Integer = 1 To 3 Dim myHyperLink As TextBox myHyperLink = New TextBox() myHyperLink.Width = New Unit(225) myTableCell.BorderStyle = BorderStyle.Solid myTableCell.BorderWidth = New Unit(1) myTableCell.Width = New Unit(700) myTableCell.BorderColor = Drawing.Color.Black myTableCell.BackColor = Drawing.Color.MistyRose myTableCell.Style.Add("text-align", "center") myTableCell.Controls.Add(myHyperLink) GVR.Cells.Add(myTableCell) Next Return GVR End Function Protected Sub b1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles b1.Click count = count + 1 Dim grsidview As Table = CType(GridView1.FindControl("Tbl"), Table) GridView1.DataBind() a = True End Sub

            Raghvendra

            C Offline
            C Offline
            Christian Graus
            wrote on last edited by
            #5

            Member 4659001 wrote:

            so when u fill the record and click to addnew row button . then bcos of postback all created row gone and so i dont find myself be able to prevent this

            Like I said, AJAX.....

            Christian Graus No longer a Microsoft MVP, but still happy to answer your questions.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups