Hi,
I have two columns - ref, description in a datagrid that has a datasource and returns a row with a reference and a description and I have a button column so that when cicked returns the ref and description into a label - works great. (I did this for testing purposes to see that I can get the data required)....read on.
Now I have a web button control (btnGetRef) that when i press I want to get the ref column data and assign it to a variable for later use.
I have tried using the function I created - "DispayBoundColumnValues", but when I enter it into the Button event handler it required a parameter and I'm not sure what.
Can anyone please help????
datagrid code:
<
asp:DataGrid runat="server" id="GridViewCables" AutoGenerateColumns="False"OnItemCommand="DisplayBoundColumnValues"
DataSourceID="ODSNoOfCables" CellPadding="4" ForeColor="#333333" GridLines="None">
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<SelectedItemStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" />
<ItemStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:ButtonColumn Text="Click Me" HeaderText="Click" />
<asp:BoundColumn DataField="ref" HeaderText="ref" />
<asp:BoundColumn DataField="cable_no" HeaderText="description" />
</Columns>
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
</asp:DataGrid>
vb code:
Sub DisplayBoundColumnValues(ByVal sender As Object, ByVal e As DataGridCommandEventArgs)Dim bc1 As String = e.Item.Cells(1).TextDim bc2 As String = e.Item.Cells(2).Text
lblBCValues.Text = bc2
End Sub
button event handler:
Protected Sub btnGetRef(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
DisplayBoundColumnValues()
End Sub