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 transfer the values of textboxes from one form to another form in datagridviw control without using database

how to transfer the values of textboxes from one form to another form in datagridviw control without using database

Scheduled Pinned Locked Moved C#
databasetutorialquestion
3 Posts 3 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.
  • U Offline
    U Offline
    User 11023286
    wrote on last edited by
    #1

    i have two forms, in one form i have three textboxes and in another form i have one datagrid view control, i want that the data i entered in textboxes will shown in datagridview control after i click on add button all the records will store in it may it is n number of record all n number of record will be shown in datagridview control but without creating database.. Is there any mechanism how to do this..????

    G P 2 Replies Last reply
    0
    • U User 11023286

      i have two forms, in one form i have three textboxes and in another form i have one datagrid view control, i want that the data i entered in textboxes will shown in datagridview control after i click on add button all the records will store in it may it is n number of record all n number of record will be shown in datagridview control but without creating database.. Is there any mechanism how to do this..????

      G Offline
      G Offline
      Ganesh KP
      wrote on last edited by
      #2

      This is so simple to do. Create a class which contains 3 properties for all three text boxes. Say for example here is the sample code

      public class Form1Class
      {
      public string TextBox1Value { get; set; }

      public string TextBox2Value { get; set; }

      public string TextBox3Value { get; set; }

      }

      Now say for example you have a button named Button1 and on the click even, you need to open Form2 and bind the textbox values to datagridview. For this, first you have to create an object of Form1Class which will take these three textbox values into my object (here it is Form1Class). Once you created an object, you need to pass the object to Form2 Here, you have to think about data passing mechanism from one form to another form (Form1 to Form2). There are many methods that we can pass data from one form to another. 1. You can use sessions, querystring etc... For detailed view of how to pass data from one form to another form in asp.net , have a look at below links MSDN article or this article also gives you an idea Null Skull link Once you pass the data from From1 to Form2 and the receiver side (i.e Form2) you need to receive the data and bind it to the datagridview. As you are passing a single object from Form1 to Form2 and you need to see how to bind an object to datagridivew. here is the stackoverflow answer on how to bind an object or a list of object(s) to a datagridview. Stack Overflow answer Once you are bind the data to a datagrid view, you can able to see the data that you enter in textbox(es) in Form1. Try this and let us know, if it is working or else facing any issues. Happy coding :)

      Regards, Ganesh

      1 Reply Last reply
      0
      • U User 11023286

        i have two forms, in one form i have three textboxes and in another form i have one datagrid view control, i want that the data i entered in textboxes will shown in datagridview control after i click on add button all the records will store in it may it is n number of record all n number of record will be shown in datagridview control but without creating database.. Is there any mechanism how to do this..????

        P Offline
        P Offline
        Pankaj Bhandari08
        wrote on last edited by
        #3

        In this case what you can do is create a custom data table in the form, having three columns as the three text box, Once you have this structure in place you can create a data row and append it to the table and set the datatable as the data source of the gridview. let me know if you have any question.

        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