Link to home
Start Free TrialLog in
Avatar of Craig_Muckleston
Craig_MucklestonFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Converting a datagrid BoundColumn to a LinkButton

I have a datagrid that is dynamically built from a query. The number of columns will always be at least 2.

When my results are bound, how can I make the cells in columns 3 onwards, linkbuttons, rather than bound columns? I know I should do it in the ItemDataBound event, but it's the actual conversion of the cell I am having.
ASKER CERTIFIED SOLUTION
Avatar of Elvio Lujan
Elvio Lujan
Flag of Argentina image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Craig_Muckleston

ASKER

Hi lem2802,

Doesn't this turn it into a hyperlink though? What I want to do is have the linkbutton so that I can drill down into the datagrid without passing the user to another page.

OK,

I've managed to create the link buttons, but I can;t get any of it's events to fire...

lnkBtn = New LinkButton
                strColVal = e.Item.Cells(3).Text
                With lnkBtn
                    .Text = strColVal
                    .Visible = True
                    .CommandName = "drill"
                    .CommandArgument = strColVal
                    .Enabled = True
                    .EnableViewState = True
                End With
Avatar of nehaya
nehaya

Edit the BoundColumn AND change it to Template
In template you can do what ever you want.

Hint using ur solution:
Did you declare the CommandName ="drill" and catch it in OnItemCommand ?
HI lem2802,

I have used your solution and passed params to another page. This works fine. I was looking for a way to do it in one page to be honest, but at least it works.