none
How to get data from GridView

Answers

  •     GridView is only used to display data, he cannot retrieve data as you expect, actually you should use the ListView.ItemContainerGenerator.ItemFromContainer call. But I still don't understand your question, when you use data binding to display data, the data source is at your control, you can do anything against it in the code behind, why do you have to retrieve the data by manipulating the view.

    Sheva
    Monday, October 09, 2006 11:40 AM

All replies

  • What do you mean by 'data'?
    Monday, October 09, 2006 9:01 AM
  • Values in the cell
    Monday, October 09, 2006 9:39 AM
  •     GridView is only used to display data, he cannot retrieve data as you expect, actually you should use the ListView.ItemContainerGenerator.ItemFromContainer call. But I still don't understand your question, when you use data binding to display data, the data source is at your control, you can do anything against it in the code behind, why do you have to retrieve the data by manipulating the view.

    Sheva
    Monday, October 09, 2006 11:40 AM
  • Scenario;

    i dynamically add textboxes to the gridview so that user inputs value into it. I am not binding data. i am actually getting the input from the user.

     

    Monday, October 09, 2006 12:06 PM
  •     Even that , data binding is still the best way to go, you can set the Binding on the textbox's Text DP as a OneWayToSource data binding.

    Sheva
    Monday, October 09, 2006 12:30 PM
  •  

    Will anyone answer the real question?  and stop goofing around?

    How do you get data from a GridView?  in a windows app its obvious that the dataset is still there, but in a web app, the dataset could be gone or changed, we want to get the value of a hidden column for the selected row.

    All the tools change, but the documentation is non-existent or does not help like it used to help in vb6. 

    we need samples!!!

    thanks

    Thursday, March 13, 2008 10:21 PM
  • I hope this helps

    protected void _BtnSubmit_Click(object sender, EventArgs e)
            {
                foreach (GridViewRow row in GridView1.Rows)
                {
                    TextBox userInputField = (TextBox)row.FindControl("TextBox_Control_ID");
                    if (userInputField != null)
                    {
                        Response.Write(userInputField.Text);

                    }
                }
            }

    By using the FindControl method you can get any control in a given row, then you can get the value of that control.
    Tuesday, May 06, 2008 9:25 PM
  • The Question is, How can i achieve that in WPF ???

    I don't know about you, but i'm thinking that GridView support in WPF is very but very limitated !!!!

    Informatic
    Thursday, June 19, 2008 11:21 AM
  • Hi Jim, here's how I did it.

    textbox1.text = GridView1.Rows(0).Cells(0).Text.ToString

    Set a breakpoint and then play with the row and cell indexes to insure you're looking at the right cell.  If you are assign it's text value to whatever control you wish.

    I hope this helps.

    - LPeoples
    • Proposed as answer by LPeoples Wednesday, July 29, 2009 4:37 PM
    Wednesday, July 29, 2009 4:37 PM
  • Hi

    I have same question of getting gridview data, but for different reason and different way,

    i want to have a functionality for user to arrange / sort the columns in gridview, i am using xtragrid from devexpress, drag and drop is allowed in gridview, if i want to save it as a report it should be saved as a custom sort. for that i want changed column order.

    if i want the entire datagrid into datatable or dataset is there any way ?

    Thanks

    Hems
    Tuesday, September 01, 2009 10:58 AM
  • "textbox1.text = GridView1.Rows(0).Cells(0).Text.ToString"...

    BUT there is NO "Rows" property for 'System.Windows.Controls.GridView'!!!!!!!!!!

    So... how do you retrive data from the gridview or listview or wherever the data is...
    Saturday, October 24, 2009 4:53 AM
  • Dim

    row As GridViewRow

    row = mygridview.SelectedRow

    textbox1.text= row.Cells(1).Text

     

     


    • Edited by wsamir Sunday, January 08, 2012 4:13 PM
    Sunday, January 08, 2012 4:11 PM
  • Thank you very much! ... I was struggle to find a way to retrieve raw data in a selected row from a specific cell. This is what I ended up with that work great:

    Session.Item("SelectedIndex_Calendar") = CalanderGridView.Rows(CalanderGridView.SelectedIndex).Cells(6).Text.ToString()

    • Edited by rdaviddd Sunday, November 03, 2013 5:52 AM
    Sunday, November 03, 2013 5:49 AM