ASP.NET: DataGrid + Get adjacent cell value

liunx

Guest
if i have an autobound datagrid, with an itemtemplate inside the template column... and there's a single LinkButton in there. I want the link button to do something with the value of the cell two columns to its right.

the linkbutton will call a method, and i'll take it as the sender. where do i go from there? looking for basically the VB.NET equivalent of parentNode.nextSibling.innerHTMLyou can only submit one value using a link button.

if you use a standard link with runat="server" then you will be able to use a databound container to bind it

<%#"d=" & Container.Bind(DataItem,"field") & "&id=" Container.Bind(DataItem,"field") %>

Only thing is that it is slow when using reflection ... but doubtful you should use it ...okay well what if i didn't actually want it to submit anything.

like if it's in a row of data, the linkbutton is just an image link. two columns to the right is an ID field. i want that ID. so say i tell the linkbutton to call a method on click... when i handle that method i just want to meaneuvre from the linkbutton (sender) to that adjacent cell.

it's basically the same as in javascript where i pass (this) and then go sender.parentNode.nextSibling.nextSibling.innerHTMLuse the dataGrids HyperLinkColumn like so

<asp:HyperLinkColumn Text="Edit" HeaderImageUrl="/images/edit.gif" DataNavigateUrlField="EventId" DataNavigateUrlFormatString="EditEvent.aspx?EventId={0}">
<HeaderStyle HorizontalAlign="Center" Width="50px"></HeaderStyle>
<ItemStyle HorizontalAlign="Center" CssClass="gridFirstItem"></ItemStyle>
</asp:HyperLinkColumn>
 
Back
Top