Well I'm not sure what is the mistake you may made, but I've built a sample
may be similar to yours, I've created a RowDataBound Event Handler for my
GridView like the following
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//string js = "javascript
:__doPostBack('GridView1','Select${0}') ";
string js =
Page.ClientScript.GetPostBackEventReference(GridVi ew1, "Select${0}");
js = String.Format(js, e.Row.RowIndex);
e.Row.Attributes["onclick"] = js;
e.Row.Style.Add("cursor", "hand");
}
}
Another way to solve the same problem but I prefer the above, Anyway test
it, you may prefer to use it:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string js = "javascript
:__doPostBack('GridView1','Select${0}') ";
js = String.Format(js, e.Row.RowIndex);
e.Row.Attributes["onclick"] = js;
e.Row.Style.Add("cursor", "hand");
}
}
I hope this could resolve your issue
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications
"CK" wrote:
I get some kind of postback callback eventvalidation error. It doesn't quite
work. Seems like I am close though. Any ideas? The error says to use
Page.ClientScript.RegisterForEventValidation
but I must be passing the wrongs args.
Thanks,
~CK
"Muhammad Mosa" <Mu**********@discussions.microsoft.comwrote in message
news:7B**********************************@microsof t.com...
You need to add code similar to the following in the GridView RowDataBound
event:
string js = Page.ClientScript.GetPostBackEventReference(YourGr idView,
"Select${0}");
js = String.Format(js, e.Row.RowIndex);
e.Row.Attributes["onclick"] = js;
e.Row.Style.Add("cursor", "hand");
where (e) is GridViewRowEventArgs
hope it helps
Regards
--
Muhammad Mosa
Software Engineer & Solution Developer
MCT/MCSD.NET
MCTS: .Net 2.0 Web Applications
MCTS: .Net 2.0 Windows Applications
"CK" wrote:
Good morning all,
I had a quick question, I would like to make a row in a gridview
selectable.
Currently there is a asp:CommandField as one of the colums. This selects
the
current row when pressed. My desire is to eliminate this column and just
make the row selectable. Any ideas?
Thanks In Advance,
~CK