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
  1. Home
  2. General Programming
  3. C#
  4. how to add row with checkboxes inside in table server control using c#

how to add row with checkboxes inside in table server control using c#

Scheduled Pinned Locked Moved C#
helptutorialcsharpjavascriptsysadmin
19 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.
  • S ShaikhAffi

    Actual SA Bhati i need to add row in table server control not in datagrid i nedd to add row in existing table the row shud contain atleas 4 to 5 textboxes hope u understood well thank u very much for the help

    S Offline
    S Offline
    SABhatti
    wrote on last edited by
    #8

    tell me briefly what your are trying to achieve? I mean what is the resulting output for the user? and and what you want from the user?

    -----

    S 1 Reply Last reply
    0
    • S SABhatti

      tell me briefly what your are trying to achieve? I mean what is the resulting output for the user? and and what you want from the user?

      -----

      S Offline
      S Offline
      ShaikhAffi
      wrote on last edited by
      #9

      well im working on an application for my father's buisness he has whole sale shop so whn a customer comes he may purchase items obviously he can purchase more than one time so im developing cash memo in tht cash memo ther are four textboxes for the itemName quantity saleprice and total and there is one button name addMoreItem so wht i want when user clicks this button same row of four textboxes shud b added every time user clicks row with the textboxes shud be added.after submitting the form whole data has to be saved in database the problem as i already told u is im unable to dynamically add row in table. hope u understand

      S 1 Reply Last reply
      0
      • S ShaikhAffi

        well im working on an application for my father's buisness he has whole sale shop so whn a customer comes he may purchase items obviously he can purchase more than one time so im developing cash memo in tht cash memo ther are four textboxes for the itemName quantity saleprice and total and there is one button name addMoreItem so wht i want when user clicks this button same row of four textboxes shud b added every time user clicks row with the textboxes shud be added.after submitting the form whole data has to be saved in database the problem as i already told u is im unable to dynamically add row in table. hope u understand

        S Offline
        S Offline
        SABhatti
        wrote on last edited by
        #10

        well the solution/sample page I gave you for gridview does exactly the same thing and I'll suggest to use gridview instead of table server control. But, if you want to use table control then you can try the same logic for that.

        -----

        S 2 Replies Last reply
        0
        • S SABhatti

          well the solution/sample page I gave you for gridview does exactly the same thing and I'll suggest to use gridview instead of table server control. But, if you want to use table control then you can try the same logic for that.

          -----

          S Offline
          S Offline
          ShaikhAffi
          wrote on last edited by
          #11

          well SA Bhatti i tried ur code the prob is u have implemented the session table tht i dont want coz if u will use session table then probably when u come back to tht page it will insert the last no: of rows

          1 Reply Last reply
          0
          • S SABhatti

            well the solution/sample page I gave you for gridview does exactly the same thing and I'll suggest to use gridview instead of table server control. But, if you want to use table control then you can try the same logic for that.

            -----

            S Offline
            S Offline
            ShaikhAffi
            wrote on last edited by
            #12

            on page load i just equals the session table to null now the problem is solved bt how can i access the each textbox in grid view well thank u very much i w8 for ur reply

            S 1 Reply Last reply
            0
            • S ShaikhAffi

              on page load i just equals the session table to null now the problem is solved bt how can i access the each textbox in grid view well thank u very much i w8 for ur reply

              S Offline
              S Offline
              SABhatti
              wrote on last edited by
              #13

              In aspx page add save button like: <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /> in code behind file do this: protected void btnSave_Click(object sender, System.EventArgs e) { foreach (GridViewRow row in gv.Rows) { TextBox tb = (TextBox)row.FindControl("tb"); string valueTyped = tb.Text; } }

              -----

              S 2 Replies Last reply
              0
              • S SABhatti

                In aspx page add save button like: <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /> in code behind file do this: protected void btnSave_Click(object sender, System.EventArgs e) { foreach (GridViewRow row in gv.Rows) { TextBox tb = (TextBox)row.FindControl("tb"); string valueTyped = tb.Text; } }

                -----

                S Offline
                S Offline
                ShaikhAffi
                wrote on last edited by
                #14

                thank u very much and wht if i want to display serial no as well and i can delete the row. i want delete button on each row so whenever i press it that row shud be deleted well i can add delete button but i dont know the logic any help will be greatly appreciated. thank

                1 Reply Last reply
                0
                • S SABhatti

                  In aspx page add save button like: <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /> in code behind file do this: protected void btnSave_Click(object sender, System.EventArgs e) { foreach (GridViewRow row in gv.Rows) { TextBox tb = (TextBox)row.FindControl("tb"); string valueTyped = tb.Text; } }

                  -----

                  S Offline
                  S Offline
                  ShaikhAffi
                  wrote on last edited by
                  #15

                  Salams ur code is giving problem when im using in page tht is using a master page sometimes it gives this error ystem.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 28: Line 29: Line 30: hf.Value = string.Empty; Line 31: Line 32: Source File: f:\erpSite\erp2\test.aspx.cs Line: 30 and onother time it gives this error System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 47: dr[0] = counter + 1; Line 48: dt.Rows.Add(dr); Line 49: gv.DataSource = dt; Line 50: gv.DataBind(); Line 51: Session["dt"] = dt; Source File: f:\erpSite\erp2\test.aspx.cs Line: 49

                  S 1 Reply Last reply
                  0
                  • S ShaikhAffi

                    Salams ur code is giving problem when im using in page tht is using a master page sometimes it gives this error ystem.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 28: Line 29: Line 30: hf.Value = string.Empty; Line 31: Line 32: Source File: f:\erpSite\erp2\test.aspx.cs Line: 30 and onother time it gives this error System.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 47: dr[0] = counter + 1; Line 48: dt.Rows.Add(dr); Line 49: gv.DataSource = dt; Line 50: gv.DataBind(); Line 51: Session["dt"] = dt; Source File: f:\erpSite\erp2\test.aspx.cs Line: 49

                    S Offline
                    S Offline
                    SABhatti
                    wrote on last edited by
                    #16

                    well, its not my code instead it is your logic that giving you the error. It seems that you are accessing the hidden field (hf) and gridview (gv) in test.aspx.cs but hf and gv are not declared in test.aspx. So check if you have declared them in this page. You should check you test.aspx page and then run in debug mode and see the cause of error. To show the sequence number on the page comment the code in rowdatabound that has row.cells[row.cells.count-1].visible = false. For deleting a row set allowdelete (you can check actual syntax in visual studio) to true and then in RowCommand delete that row from the gridview and from the datatable in session. (you can find the row based on the sequence number and delete it from the session).

                    -----

                    S 3 Replies Last reply
                    0
                    • S SABhatti

                      well, its not my code instead it is your logic that giving you the error. It seems that you are accessing the hidden field (hf) and gridview (gv) in test.aspx.cs but hf and gv are not declared in test.aspx. So check if you have declared them in this page. You should check you test.aspx page and then run in debug mode and see the cause of error. To show the sequence number on the page comment the code in rowdatabound that has row.cells[row.cells.count-1].visible = false. For deleting a row set allowdelete (you can check actual syntax in visual studio) to true and then in RowCommand delete that row from the gridview and from the datatable in session. (you can find the row based on the sequence number and delete it from the session).

                      -----

                      S Offline
                      S Offline
                      ShaikhAffi
                      wrote on last edited by
                      #17

                      i have checked hf and gv already exist in the page it gives the same error i told u wht shud i do

                      1 Reply Last reply
                      0
                      • S SABhatti

                        well, its not my code instead it is your logic that giving you the error. It seems that you are accessing the hidden field (hf) and gridview (gv) in test.aspx.cs but hf and gv are not declared in test.aspx. So check if you have declared them in this page. You should check you test.aspx page and then run in debug mode and see the cause of error. To show the sequence number on the page comment the code in rowdatabound that has row.cells[row.cells.count-1].visible = false. For deleting a row set allowdelete (you can check actual syntax in visual studio) to true and then in RowCommand delete that row from the gridview and from the datatable in session. (you can find the row based on the sequence number and delete it from the session).

                        -----

                        S Offline
                        S Offline
                        ShaikhAffi
                        wrote on last edited by
                        #18

                        the second problem is as i told u i have a textbox named item there is a button besides tht textbox on each row when i click tht button a pop up shud be open well i opened the pop through the javascript now i want to pass the client id of tht textbox i mean item to tht javascript function which is calling the pop.so plz help me out this problem is driving me crazy any help wud greatly be appreciated i will wait for ur reply u have solved my prob until now this is the last problem plz do me favour thank u very much

                        1 Reply Last reply
                        0
                        • S SABhatti

                          well, its not my code instead it is your logic that giving you the error. It seems that you are accessing the hidden field (hf) and gridview (gv) in test.aspx.cs but hf and gv are not declared in test.aspx. So check if you have declared them in this page. You should check you test.aspx page and then run in debug mode and see the cause of error. To show the sequence number on the page comment the code in rowdatabound that has row.cells[row.cells.count-1].visible = false. For deleting a row set allowdelete (you can check actual syntax in visual studio) to true and then in RowCommand delete that row from the gridview and from the datatable in session. (you can find the row based on the sequence number and delete it from the session).

                          -----

                          S Offline
                          S Offline
                          ShaikhAffi
                          wrote on last edited by
                          #19

                          please help me out well i done all these things by my self now the only problem remains is when i reload or refresh my page automatically row is inserted i dont want this please reply

                          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