Help needed on using buttoncolumn in datagrid

  • Thread starter Lenin Sakthees via .NET 247
  • Start date
L

Lenin Sakthees via .NET 247

Hi all,
I am using a datagrid to show values from a SQL table.
My problem is, I want to show the details of the each row when the user clicks the 'View details' buttoncolumn.
I am able to fire a event when the user clicks the button column

here is my html for the datagrid
**************************************************************************************
<Columns>
<asp:HyperLinkColumn Target="_blank" DataNavigateUrlField="Title" DataNavigateUrlFormatString="SelectedTitle.aspx?title={0}"
DataTextField="Title" SortExpression="Title" HeaderText="TITLE"></asp:HyperLinkColumn>
<asp:BoundColumn DataField="Author" HeaderText="AUTHOR"></asp:BoundColumn>
<asp:BoundColumn DataField="Year" HeaderText="YEAR">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
</asp:BoundColumn>
<asp:ButtonColumn ButtonType="LinkButton" text="View Details" CommandName="select"></asp:ButtonColumn>
</Columns>
***************************************************************************************
when i try to capture the column values and write it to a label, it returns empty string to the label
here is the code that i am using,

Dim buttonColumn As TableCell = e.Item.Cells(0)
Dim buttonColText As String = buttonColumn.Text
Label1.Text = buttonColText
how should i go about doing that. any help is appreciated.
Thank you
 
E

Elton Wang

Hi Lenin,

Actually the first column in the datagrid is a hyperlink
column. So you may use

e.Item.Cells(1)

HTH

Elton Wang
(e-mail address removed)

-----Original Message-----
Hi all,
I am using a datagrid to show values from a SQL table.
My problem is, I want to show the details of the each row
when the user clicks the 'View details' buttoncolumn.
I am able to fire a event when the user clicks the button column

here is my html for the datagrid
********************************************************** ****************************
<Columns>
<asp:HyperLinkColumn Target="_blank" DataNavigateUrlField="Title"
DataNavigateUrlFormatString="SelectedTitle.aspx?title={0}"
DataTextField="Title"
SortExpression="Title"
HeaderText="TITLE"> said:
<asp:BoundColumn DataField="Author"
HeaderText="AUTHOR"> said:
<asp:BoundColumn DataField="Year" HeaderText="YEAR">
<ItemStyle
HorizontalAlign="Left"> said:
</asp:BoundColumn>
<asp:ButtonColumn ButtonType="LinkButton"
text="View Details"
CommandName="select"> said:
</Columns>
********************************************************** *****************************
when i try to capture the column values and write it to a
label, it returns empty string to the label
 

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

Top