Craig_Muckleston
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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
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
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 ?
In template you can do what ever you want.
Hint using ur solution:
Did you declare the CommandName ="drill" and catch it in OnItemCommand ?
ASKER
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.
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.
ASKER
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.