Help a newbie... (DataGrid bound & template columns)

G

Guest

Hello,

I have a DataGrid that has a template col with an asp:LinkButton tag in it.

When the LinkButton is clicked for this row, the onClick handler needs to do
some things with some various data items from this row and eventually modify
other data items in the same row before rebinding the whole thing.

But how do I get at the data fields in the "parent row" of the LinkButton
that was clicked? What is the syntax?

Thanks,

David
 
R

Roy

OMG. I'm actually posting an "answer" to this ng...not just a question.
:) It's a first.

Dave, firstly, you mention using a linkbutton... Why specificly?
Linking to another page seems to imply other things going on here...

Secondly, to find out how to gain access to various specific cells in a
datagrid, research "editing a datagrid," (there are a million sites
online about it) and look for the Sub where the page is updated. This
will teach you easily.

It's not involved. Something like "E.Item.Cells(6).Controls(0)"
references the 6th cell in the currently selected record.

Something like "Dim strXYZ As String = E.Item.Cells(6).Text" declares a
string variable and sets the cell's contents to it.
 
V

Vadivel Kumar

When you use Itemtemplate to bind a control
like any literal controls, you have to
get the handle of the control by using FindControl() like this,

LinkButton l = (LinkButton) e.Item.FindControl("LinkButtonID");

This will find the control and assign it to the object l, you can do any
kind of manipulation with the l and that
will be replicated to the actual control located in
the page.

Hope, this helps you.

Thanks & Regards
Vadivel Kumar
http:\\csharpblogs.blogspot.com
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top