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

Get a column value from a grid row when linkbutton in grid row is clicked

2 Answers 225 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Acadia
Top achievements
Rank 1
Iron
Acadia asked on 22 Aug 2008, 08:47 PM
How would you do this?  I have a custom sub being called in the OnClick of a link button in my grid:

<telerik:GridBoundColumn DataField="TRANS_AMOUNT" HeaderText="Amount" UniqueName="TRANS_AMOUNT"

ReadOnly="True">

<HeaderStyle HorizontalAlign="Left" Width="100px" Wrap="False" />

<ItemStyle HorizontalAlign="Right" Width="100px" Wrap="False" />

</telerik:GridBoundColumn>

<telerik:GridTemplateColumn DataField="USE_TAX_AMT" HeaderText="Use Tax" UniqueName="USE_TAX_AMT"

AllowFiltering="False">

<HeaderStyle HorizontalAlign="Left" Width="45px" Wrap="False" />

<ItemStyle HorizontalAlign="Right" Width="45px" Wrap="False" />

<ItemTemplate>

<asp:LinkButton ID="lbUseTax" runat="server" CommandName="Taxes" Width="45px" CssClass="Normal"

ToolTip="Click to edit use Tax" Text='<%#DataBinder.Eval(Container, "DataItem.USE_TAX_AMT") %>'

OnClick="useTaxClick"></asp:LinkButton>

</ItemTemplate>

</telerik:GridTemplateColumn>

'-----------------------------------------------------------------------------------------------

Public Sub useTaxClick(ByVal sender As Object, ByVal e As System.EventArgs)

'need to get the value from the grid column TRANS_AMOUNT to pass as parameter to the window
Dim taxable As Double = 0

Dim newWindow As New Telerik.Web.UI.RadWindow
newWindow.ID =
"txW"
newWindow.NavigateUrl = "PurchaseCardUseTax.aspx?taxable=" & taxable newWindow.VisibleOnPageLoad = True

Master.Page.Form.Controls.Add(newWindow)

End Sub

But how do I access the TRANS_AMOUNT column value for the row where the link button was clicked?  Neither sender nor e is capable of representing the row.

Thanks


2 Answers, 1 is accepted

Sort by
0
Accepted
Princy
Top achievements
Rank 2
answered on 25 Aug 2008, 05:45 AM
Hello Acadia,

To get an item value on clicking a LinkButton on the same row in the Grid, you can try the code below.
cs:
 Protected Sub useTaxClick(ByVal sender As Object, ByVal e As EventArgs) 
    Dim lnkbtn As LinkButton = DirectCast(sender, LinkButton) 
    Dim item As GridDataItem = DirectCast(lnkbtn.NamingContainer, GridDataItem) 
    Dim strtxt As String = item("TRANS_AMOUNT").Text 
 End Sub 

Thanks
Princy.
0
Acadia
Top achievements
Rank 1
Iron
answered on 25 Aug 2008, 02:23 PM
That worked perfectly, thanks Princy!
Tags
Grid
Asked by
Acadia
Top achievements
Rank 1
Iron
Answers by
Princy
Top achievements
Rank 2
Acadia
Top achievements
Rank 1
Iron
Share this question
or