Help on data-grid

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • aspamit
    New Member
    • Jan 2007
    • 38

    Help on data-grid

    Hi all,
    I am displaying data in data-grid using dataset.Now I want to select row of data-grid and fetch the values into it in text-boxes on the same page.

    I mean I want to select the row i.e, by clicking it I can get the values into it.

    Any help is appreciated.
    Thank u.
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Here is an article that may help:
    An Extensive Examination of the DataGrid Web Control

    Comment

    • aspamit
      New Member
      • Jan 2007
      • 38

      #3
      Originally posted by kenobewan
      thanks,
      but I don't want to update or edit data in datagrid their only.Rather I want to select a particular row and on click event I want to get the values in that row.
      And want to display these records in text-boxes outside of data-grid.

      Pls help.

      Comment

      • aaryan
        New Member
        • Nov 2006
        • 82

        #4
        Originally posted by aspamit
        thanks,
        but I don't want to update or edit data in datagrid their only.Rather I want to select a particular row and on click event I want to get the values in that row.
        And want to display these records in text-boxes outside of data-grid.

        Pls help.
        hi aspamit,
        when you are defining the datagrid, set its itemcommand property also. for eg.
        <asp:DataGrid id = ..... OnItemCommand = "grid_selectcom mand"/>
        while defining its columns,
        <columns>
        <asp:BoundColum n HeaderText = "Select" Buttontype= "Pushbutton " text = "select" commandname = "Select"/>
        i hope till here you would have followed.
        now in your code,
        void grid_selectcomm and(object sender,DataGrid CommandEventArg s e)
        {
        Tablecell itemcell1 = e.item.cells[1]
        Tablecell itemcell2 = e.item.cells[2]
        and so on
        here e.item is the row of the table where the command is raised.
        for bound columns the value is stored in the text property of the tablecell.
        so to retrieve the values in the textboxes outside the data grid, you can give text1.text = itemcell1.text
        text2.text = itemcell2.text and so on (assuming you have declared textboxes in your web page.
        hope this helps. any doubts or error pls feel free to post it again.

        Comment

        • aspamit
          New Member
          • Jan 2007
          • 38

          #5
          Originally posted by aaryan
          hi aspamit,
          when you are defining the datagrid, set its itemcommand property also. for eg.
          <asp:DataGrid id = ..... OnItemCommand = "grid_selectcom mand"/>
          while defining its columns,
          <columns>
          <asp:BoundColum n HeaderText = "Select" Buttontype= "Pushbutton " text = "select" commandname = "Select"/>
          i hope till here you would have followed.
          now in your code,
          void grid_selectcomm and(object sender,DataGrid CommandEventArg s e)
          {
          Tablecell itemcell1 = e.item.cells[1]
          Tablecell itemcell2 = e.item.cells[2]
          and so on
          here e.item is the row of the table where the command is raised.
          for bound columns the value is stored in the text property of the tablecell.
          so to retrieve the values in the textboxes outside the data grid, you can give text1.text = itemcell1.text
          text2.text = itemcell2.text and so on (assuming you have declared textboxes in your web page.
          hope this helps. any doubts or error pls feel free to post it again.

          Thanks for ur help Aaryan.
          I don't want any button on my data-grid to display.
          What u told is there is a button for each row in data-grid and the user should click that button to select that row.
          Instead I want to raise onclick event in any part of the row.

          Pls help.

          Comment

          • aaryan
            New Member
            • Nov 2006
            • 82

            #6
            Originally posted by aspamit
            Thanks for ur help Aaryan.
            I don't want any button on my data-grid to display.
            What u told is there is a button for each row in data-grid and the user should click that button to select that row.
            Instead I want to raise onclick event in any part of the row.

            Pls help.
            ok do you mean that if you click any part of the row say a particular column, only that column's value shd appear in the text box or the entire row. pls verify this for me and we shall proceed.

            Comment

            • aspamit
              New Member
              • Jan 2007
              • 38

              #7
              Originally posted by aaryan
              ok do you mean that if you click any part of the row say a particular column, only that column's value shd appear in the text box or the entire row. pls verify this for me and we shall proceed.

              Ya I should b able to click on any part of the row.And should b able to catch the values in that row in Text-boxes outside data-grid.

              u r thinking on the same line?

              Pls help.It's urgent.

              Comment

              • aaryan
                New Member
                • Nov 2006
                • 82

                #8
                Originally posted by aspamit
                Ya I should b able to click on any part of the row.And should b able to catch the values in that row in Text-boxes outside data-grid.

                u r thinking on the same line?

                Pls help.It's urgent.
                hi amit,
                check if this site is of any use to you until i try to work some other way.
                http://www.codeproject .com/aspnet/dgrowselect.asp

                Comment

                • aspamit
                  New Member
                  • Jan 2007
                  • 38

                  #9
                  Originally posted by aaryan
                  hi amit,
                  check if this site is of any use to you until i try to work some other way.
                  http://www.codeproject .com/aspnet/dgrowselect.asp
                  Hi aaryan,
                  r u trying 2 solve my problem.

                  Comment

                  • aaryan
                    New Member
                    • Nov 2006
                    • 82

                    #10
                    Originally posted by aspamit
                    Hi aaryan,
                    r u trying 2 solve my problem.
                    sorry amit,
                    i am yet to resolve it. i hope somebody else will help us too.

                    Comment

                    • ashasprabhu
                      New Member
                      • Jan 2007
                      • 52

                      #11
                      hi,
                      here is alink
                      http://aspalliance.com/136_DataGrid_an d_Checkboxes
                      in this example the author has used the lablebox instead u can use a textbox
                      hope this helps u
                      with regards
                      Asha S

                      Comment

                      • aspamit
                        New Member
                        • Jan 2007
                        • 38

                        #12
                        Originally posted by ashasprabhu
                        hi,
                        here is alink
                        http://aspalliance.com/136_DataGrid_an d_Checkboxes
                        in this example the author has used the lablebox instead u can use a textbox
                        hope this helps u
                        with regards
                        Asha S
                        Thanks for ur reply.But I am already through it.I used a button column instead.But I don't want to restrict user to click on that button for selecting row instead he should be to click on any part of the row on datagrid and accordingly select those values.

                        Comment

                        • nb123
                          New Member
                          • Feb 2007
                          • 1

                          #13
                          Originally posted by aspamit
                          Thanks for ur reply.But I am already through it.I used a button column instead.But I don't want to restrict user to click on that button for selecting row instead he should be to click on any part of the row on datagrid and accordingly select those values.

                          Hi Amit!
                          I would be really grateful if u could give me the steps of how u went abt it. because i also need to do the same thing.
                          Please paste code snippets if possible.
                          Thanks.

                          Comment

                          • aspamit
                            New Member
                            • Jan 2007
                            • 38

                            #14
                            Originally posted by nb123
                            Hi Amit!
                            I would be really grateful if u could give me the steps of how u went abt it. because i also need to do the same thing.
                            Please paste code snippets if possible.
                            Thanks.
                            I will definitely help u.
                            But b patient

                            Comment

                            • maheshv1984
                              New Member
                              • Feb 2007
                              • 1

                              #15
                              hi dear,
                              i tried to get this problems solution.i am working in asp.net 2.0.In asp2 this is not working properly...it is showing identifier error.if possible let me know the solution...
                              bye

                              Originally posted by aaryan
                              hi aspamit,
                              when you are defining the datagrid, set its itemcommand property also. for eg.
                              <asp:DataGrid id = ..... OnItemCommand = "grid_selectcom mand"/>
                              while defining its columns,
                              <columns>
                              <asp:BoundColum n HeaderText = "Select" Buttontype= "Pushbutton " text = "select" commandname = "Select"/>
                              i hope till here you would have followed.
                              now in your code,
                              void grid_selectcomm and(object sender,DataGrid CommandEventArg s e)
                              {
                              Tablecell itemcell1 = e.item.cells[1]
                              Tablecell itemcell2 = e.item.cells[2]
                              and so on
                              here e.item is the row of the table where the command is raised.
                              for bound columns the value is stored in the text property of the tablecell.
                              so to retrieve the values in the textboxes outside the data grid, you can give text1.text = itemcell1.text
                              text2.text = itemcell2.text and so on (assuming you have declared textboxes in your web page.
                              hope this helps. any doubts or error pls feel free to post it again.

                              Comment

                              Working...