Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Accessing the value of a cell in a datagrid

Reply
Thread Tools

Accessing the value of a cell in a datagrid

 
 
amazon otter via .NET 247
Guest
Posts: n/a
 
      04-16-2004
Hi,
I've been researching in how to do this for 3 days now. I'mdisplaying a datagrid, DATAGRID1, that has for instance 3columns and 5 rows. The column headers are Employee, Day1, andDay2. Each column may or may not have string data in them.
------DATAGRID1-----------------
Employee Day1 Day2
John S
Sam A
Joe D
Jen F
Nick T
--------------------------------

The row values are Linkbuttons. So when a user clicks on say,"S", for John under Day1, my datagrid does an OnItemCommandevent to a Sub called "Process_OnItemCommand".

I need for this Sub to give me the Cell index that it resides in.I know how to get the row index by using, e.item.itemindex, butI really need to know how to get the Cell(Column) index. Allthe examples I've seen so far have syntax like, LABELx.text =CType(e.Item.Cells(1).FindControl("LABELy"), label).text, whereCells(1) actually means something to them.

I do not have the luxury of knowing which cell was selected or doI? Am I missing something? Is their a way of finding theColumn Index. The reason I am trying to do this is so that Ican take the value that was selected and remove it from theDataset and eventually the re-painted datagrid.

Thanks

From: amazon otter

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>0VIjK+hQ/Ue0cfG0+RIohQ==</Id>
 
Reply With Quote
 
 
 
 
Prodip Saha
Guest
Posts: n/a
 
      04-19-2004
You may not have to use the Cell reference. Here is an example that may
help---
LinkButton lnkButton= (LinkButton) e.Item.FindControl("Name of the link
button");

//If there is a link button with the name above exist then the variable
lnkButton will be
//mapped.

if(lnkButton!=null)
{
//do something;
}

We should NEVER rely on the positioning.
Prodip
"amazon otter via .NET 247" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
Hi,
I've been researching in how to do this for 3 days now. I'm displaying a
datagrid, DATAGRID1, that has for instance 3 columns and 5 rows. The column
headers are Employee, Day1, and Day2. Each column may or may not have
string data in them.
------DATAGRID1-----------------
Employee Day1 Day2
John S
Sam A
Joe D
Jen F
Nick T
--------------------------------

The row values are Linkbuttons. So when a user clicks on say, "S", for John
under Day1, my datagrid does an OnItemCommand event to a Sub called
"Process_OnItemCommand".

I need for this Sub to give me the Cell index that it resides in. I know
how to get the row index by using, e.item.itemindex, but I really need to
know how to get the Cell(Column) index. All the examples I've seen so far
have syntax like, LABELx.text = CType(e.Item.Cells(1).FindControl("LABELy"),
label).text, where Cells(1) actually means something to them.

I do not have the luxury of knowing which cell was selected or do I? Am I
missing something? Is their a way of finding the Column Index. The reason
I am trying to do this is so that I can take the value that was selected and
remove it from the Dataset and eventually the re-painted datagrid.

Thanks

From: amazon otter

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

<Id>0VIjK+hQ/Ue0cfG0+RIohQ==</Id>


 
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
Accessing value of hidden table cell chris ASP .Net 2 06-26-2008 01:27 PM
accessing datagrid cell Sam ASP .Net 3 04-02-2006 09:50 PM
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
RadioButtonList In A DataGrid Cell - Can I find the selected button without editing the cell? Empire City ASP .Net Datagrid Control 3 04-30-2004 12:19 AM
moving to cell Y if cell X has value Z. Clarke Rice Computer Support 0 06-30-2003 09:35 AM



Advertisments