This is a migrated thread and some comments may be shown as answers.

Stupid question

1 Answer 63 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Spacewarp
Top achievements
Rank 1
Spacewarp asked on 05 Feb 2009, 09:47 PM
I've got a grid with 5 columns. 

First column has a document type name in it. 

The last column has a button to allow you to update the version of the file on the server.

I've tried a handful of different things to be able to get the button clicked and actually get the value of the document type column for the row the button is clicked on.

(I am not pasting code for a specific reason right now.  Just too many internal pieces of information for my client and they'd be frustrated if I posted details of their project.  Also, I've not finished with my workaround yet, so I figure best to just ask the simple question and then correct the code when it's done.)

What I'm currently in the process of doing:

Creating an ImageButton imbedded in a gridtemplatecolumn. 
Set the DataValue of the gridtemplatecolumn to the name object from the table.
Set the AlternateText value to the Imagebutton to eval from the datavalue.
On the fire event, parse the AlternateText value to get the argument to send to the file upload page with the document type.

Any ideas as to whether that will actually work?
I know it's a cheat, but how do I do it without kludging it.

I'm down to just a few minor features and a few bug fixes to get this out the door.

Thanks.

Paul

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 06 Feb 2009, 05:29 AM
Hello Paul,

You can try out the following code to access a cell text on clicking a button in the same row:
cs:
 protected void Button_Click1(object sender, EventArgs e) 
    { 
        ImageButton btn = (ImageButton)sender; 
        GridDataItem dataItem = (GridDataItem)btn.NamingContainer
        string strtxt = dataItem["DocumentTypeName"].Text; // where DocumentTypeName is the column UniqueName      
         
    } 

Thanks
Princy.
Tags
Grid
Asked by
Spacewarp
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or