A program about get value from datagrid cell

Discussion in 'ASP .Net Web Controls' started by Jet, Jun 17, 2005.

  1. Jet

    Jet Guest

    Hi,all
    I have a asp.net programme,and it include a datagrid contorl in it.And all
    the data from the datagrid is come from a access mdb.And I had use like
    <$#DataBinder.Eval(Containter.DataItem,"name")%> to binding data. And in
    this datagrid control there is a delete command , when I active this command
    I want to get the value of column 2 in this row and the visable of this
    column is false.How can I get it?
    I had try the code like this,but can't get any value .
    private int DataGrid1_DeleteCommand(object source,DataGridCommandEventArgs
    e){
    int i=e.Item.Cells[1].Text;
    }
    How can I get the select cell's value in current selected row?
    Jet, Jun 17, 2005
    #1
    1. Advertising

  2. Jet

    melk Guest

    Hi!

    You can get all the value directly from the dataSource table...

    If you felt datagrid with a datatable, you can write this on your "del
    event":

    DataTable dt = (DataTable)yourDataGrid.dataSource;
    int itemId = e.Item.ItemIndex + (yourDataGrid.CurrentPageIndex *
    yourDataGrid.PageSize);

    int i = dt[itemId]["id"];

    now you have all the records... hidden too!!!

    bye

    Melk


    "Jet" <> ha scritto nel messaggio
    news:...
    > Hi,all
    > I have a asp.net programme,and it include a datagrid contorl in it.And all
    > the data from the datagrid is come from a access mdb.And I had use like
    > <$#DataBinder.Eval(Containter.DataItem,"name")%> to binding data. And in
    > this datagrid control there is a delete command , when I active this
    > command I want to get the value of column 2 in this row and the visable of
    > this column is false.How can I get it?
    > I had try the code like this,but can't get any value .
    > private int DataGrid1_DeleteCommand(object source,DataGridCommandEventArgs
    > e){
    > int i=e.Item.Cells[1].Text;
    > }
    > How can I get the select cell's value in current selected row?
    >
    melk, Jun 17, 2005
    #2
    1. Advertising

  3. Jet

    melk Guest

    Sorry I wrote :

    int i = dt[itemId]["id"];

    but I mean :

    int i = dt.Rows[itemId]["id"];



    "Jet" <> ha scritto nel messaggio
    news:...
    > Hi,all
    > I have a asp.net programme,and it include a datagrid contorl in it.And all
    > the data from the datagrid is come from a access mdb.And I had use like
    > <$#DataBinder.Eval(Containter.DataItem,"name")%> to binding data. And in
    > this datagrid control there is a delete command , when I active this
    > command I want to get the value of column 2 in this row and the visable of
    > this column is false.How can I get it?
    > I had try the code like this,but can't get any value .
    > private int DataGrid1_DeleteCommand(object source,DataGridCommandEventArgs
    > e){
    > int i=e.Item.Cells[1].Text;
    > }
    > How can I get the select cell's value in current selected row?
    >
    melk, Jun 17, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. steve roszko
    Replies:
    1
    Views:
    1,829
    steve
    Aug 12, 2003
  2. Niclas Lindblom

    Get cell string value from datagrid

    Niclas Lindblom, Apr 21, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    8,985
    Niclas Lindblom
    Apr 21, 2004
  3. =?Utf-8?B?UGF1bA==?=

    datagrid-how to get cell value(hyperlink column)

    =?Utf-8?B?UGF1bA==?=, Oct 12, 2004, in forum: ASP .Net
    Replies:
    9
    Views:
    8,861
    =?Utf-8?B?UGF1bA==?=
    Oct 13, 2004
  4. Empire City
    Replies:
    3
    Views:
    387
    Empire City
    Apr 30, 2004
  5. RJ
    Replies:
    1
    Views:
    228
    Eliyahu Goldin
    Feb 17, 2005
Loading...

Share This Page