Home All Groups Group Topic Archive Search About

A program about get value from datagrid cell

Author
17 Jun 2005 7:52 AM
Jet
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?

Author
17 Jun 2005 9:47 AM
melk
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


Show quoteHide quote
"Jet" <liang***@126.com> ha scritto nel messaggio
news:uTt9xFxcFHA.2736@TK2MSFTNGP12.phx.gbl...
> 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?
>
Author
17 Jun 2005 9:56 AM
melk
Sorry I wrote :

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

but I mean :

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



Show quoteHide quote
"Jet" <liang***@126.com> ha scritto nel messaggio
news:uTt9xFxcFHA.2736@TK2MSFTNGP12.phx.gbl...
> 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?
>