textbox to datagrid in asp.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rakeshpatil1234
    New Member
    • Jan 2008
    • 9

    textbox to datagrid in asp.net

    i have 2 text box ,1 button and data grid .
    i want to add textbox's values to datagrid on button click

    plz help me
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    Originally posted by rakeshpatil1234
    i have 2 text box ,1 button and data grid .
    i want to add textbox's values to datagrid on button click

    plz help me
    Here are 2 different ways to accomplish this.
    1. You can create an arraylist and add the text from each textbox to the arraylist. Then assign the datasource of your datagrid to the arraylist. Then call DataBind().
    2. You could use 2 Template Columns in your datagrid. Add a label control in each Template column and set the text of each label = to the text of textbox1 and textbox2.

    Try either one and let me know if you run into any problems.

    Nathan

    Comment

    • rakeshpatil1234
      New Member
      • Jan 2008
      • 9

      #3
      can u give me c# code for it i am not able to add it to grid using arraylist

      Comment

      • kenobewan
        Recognized Expert Specialist
        • Dec 2006
        • 4871

        #4
        Originally posted by rakeshpatil1234
        can u give me c# code for it i am not able to add it to grid using arraylist
        Please don't simply ask for code. As Nathan said, TRY it and report back if you have problems. Thanks.

        MODERATOR

        Comment

        • nateraaaa
          Recognized Expert Contributor
          • May 2007
          • 664

          #5
          Originally posted by rakeshpatil1234
          can u give me c# code for it i am not able to add it to grid using arraylist
          If the arraylist doesn't work for you. Then you could add the text from the textboxes to a datatable, a dataset, an array. There are many data containers you can use as a datasource.

          Nathan

          Comment

          Working...