I want to make a listview row clickable without using a button. the listview is filled with data out of a database so putting a onclick methode directly on the tr isnt a option.
I found this tread: http://forums.asp.net/t/1419161.aspx
But i get the error: " registerforeventvalidation can only be called during render()" at line:
string script = this.ClientScript.GetPostBackClientHyperlink(btn, "", true);
This is fixable by setting " enableEventValidation="false" " at @Page directive.
Now my question:
i prefer listview but if there is a better way that involves some other grid like control i would also like to hear that.
i am making this in asp.net VB.net but c# example is also fine.
Thanks!
You can do this from a database. In the example below clicking on the row will call a javascript function called evalItem, and pass the "Publisher" field from the data item for the row bound to the listview.
<ItemTemplate>
<tr class="clsGroupRowSelectable" onclick='evalItem('<%# Eval("Publisher").ToString() %>');'>
<td><%# Eval("Number") %>' /></td>
</tr>
</ItemTemplate>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.