Sunday, March 11, 2012

Value of LinkButton in ItemCommand Event

Hi Suzanne!
What you need to do is refer to the LinkButton's Text property instead of the Cell's Text property. (The cell itself will only have Text if raw output is placed into the cell, but will not if controls are present).
<td>Cell's Text</td> -- can use e.Item.Cells(x).Text
<td><a href="http://links.10026.com/?link=dopostback(something)">LinkButton's Text</a></td> -- need: e.Item.Cells(0).Controls(0).Text
And if you're using Option Strict, you'll need to cast "Controls(0)" to a LinkButton:
Session("Month") = CType(e.Item.Cells(0).Controls(0), LinkButton).Text
Hope that helps!
Marcie

No comments:

Post a Comment