Hi all,
We have DataGrid control in Web Form, our client requires to be able to
click anywhere of a row to fire the event same as LinkBotton column is
clicked. We we did in ASP.NET 1.1 is
in ASPX page
<asp:DataGrid id="MyGrid" runat="server" AutoGenerateCol umns="False"
AllowSorting="T rue" AllowPaging="Tr ue" runat="server"
EnableViewState ="True">
<Columns>
<asp:ButtonColu mn Text="" CommandName="Se lect" Visible="false" />
<asp:BoundColum n DataField="MyTe xt" SortExpression= "" />
</Columns>
<PagerStyle Mode="NumericPa ges" />
</asp:DataGrid>
in code-behind
private void MyGrid_ItemData Bound(object sender,
System.Web.UI.W ebControls.Data GridItemEventAr gs e) {
if (e.Item.ItemTyp e == ListItemType.It em
|| e.Item.ItemType == ListItemType.Al ternatingItem
|| e.Item.ItemType == ListItemType.Se lectedItem) {
LinkButton button = (LinkButton)e.I tem.Cells[0].Controls[0];
e.Item.Attribut es["onclick"] = Page.GetPostBac kClientHyperlin k(button,
"");
}
}
private void dLeads_ItemComm and(object source,
System.Web.UI.W ebControls.Data GridCommandEven tArgs e) {
if (e.CommandName == "Select") {
// my logic
}
}
Basically, the idea is to hijack the event of ButtonColum of DataGrid to set
to the <TR>.
After I converted the code to ASP.NET 2.0, I cannot use this logic any more,
because I get "Invalid postback or callback argument. Event validation is
enabled using in configuration or in a page. For security purposes, this
feature verifies that arguments to postback or callback events originate
from the server control that originally rendered them. If the data is valid
and expected, use the ClientScriptMan ager.RegisterFo rEventValidatio n method
in order to register the postback or callback data for validation." error
message, unless I turn EnableEventVali dation of the page off. And I don't
think RegisterForEven tValidation can work with my situation.
Anybody has idea, what is the solution in ASP.NET 2.0?
--
WWW: http://www.imagestation.com/members/hardywang
ICQ: 3359839
yours Hardy