I doubt the id of the Button is changed. As the button control is inside the template column the control id will be changed. Apply a CSS to the Button control and use that css for the attaching the click event
Check the View Source of the Page
Code:
<asp:TemplateColumn HeaderText="Description">
<ItemTemplate>
<asp:Label runat="server" Text='<%# GetDescription(Container.DataItem) %>' />
<asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %>' Visible="false"/>
<asp:Button runat="server" Text="..." ID="btn" CssClass="btn" />
</ItemTemplate>
</asp:TemplateColumn>
And the Jquery Event
Code:
<script type="text/javascript" src="~/Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//Find the button based on css btn and attach the evnet
$(' .btn').click(function () {
// find previous two labels
var longLabel = $(this).prev();
var shortLabel = longLabel.prev();
longLabel.css('display', 'inline'); // show long descr
shortLabel.css('display', 'none'); // hide short descr
return false; // prevent post-back?
});
});
</script>
Or else you could change the Jquery as
Code:
<script type="text/javascript" src="~/Scripts/jquery-1.4.1.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//Find the button based on css btn and attach the evnet
$(' .btn').bind('click',function () {
// find previous two labels
var longLabel = $(this).prev();
var shortLabel = longLabel.prev();
longLabel.css('display', 'inline'); // show long descr
shortLabel.css('display', 'none'); // hide short descr
return false; // prevent post-back?
});
});
</script>