Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > A program about get value from datagrid cell

Reply
Thread Tools

A program about get value from datagrid cell

 
 
Jet
Guest
Posts: n/a
 
      06-17-2005
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?


 
Reply With Quote
 
 
 
 
melk
Guest
Posts: n/a
 
      06-17-2005
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" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
> 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?
>



 
Reply With Quote
 
 
 
 
melk
Guest
Posts: n/a
 
      06-17-2005
Sorry I wrote :

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

but I mean :

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



"Jet" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
> 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?
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set cell background based on cell value when datagrid is displayed RJ ASP .Net Datagrid Control 1 02-17-2005 09:37 PM
datagrid-how to get cell value(hyperlink column) =?Utf-8?B?UGF1bA==?= ASP .Net 9 10-12-2004 11:39 PM
Get cell string value from datagrid Niclas Lindblom ASP .Net 2 04-21-2004 11:26 AM
Get value from datagrid DDL cell OnSelectedIndexChange steve roszko ASP .Net 1 08-12-2003 08:46 PM
moving to cell Y if cell X has value Z. Clarke Rice Computer Support 0 06-30-2003 09:35 AM



Advertisments