J
JC
Hi!
I have a datagrid in c#. When you move the mouse over the lines they
highlight. What I really want is for the user to be able to click
anywhere on a line and the 'SelectedIndexChanged' event be called -
enabling me to open another page to edit that selected record.
So, firstly I added a bound Select button, and as expected when I
click the SelectedIndexChanged event gets called, next stage was to
make that button invisible but add the following code to the datagrid
ItemDataBound event...
//This highlights on mouse over - works fine!
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='Silver';this.style.color='white';this.style.cursor='hand'");
//this unhighlights on mouseout - works fine also!
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white';this.style.color='black';this.style.cursor='hand'");
//this calls the doPostBakc function passing parameters just as the
'select' button does, but it doesnt call the SelectedIndexChanged
event :'(
e.Item.Attributes.Add("onclick","javascript:__doPostBack('" +
"dgAllPosts:" + "_ctl" + 1 + ":_ctl0','')");
Anyways, if anyone can see what I'm doing wrong, or has a better way
to achieve this, I'd love to hear from you.
Thanks chaps
James
I have a datagrid in c#. When you move the mouse over the lines they
highlight. What I really want is for the user to be able to click
anywhere on a line and the 'SelectedIndexChanged' event be called -
enabling me to open another page to edit that selected record.
So, firstly I added a bound Select button, and as expected when I
click the SelectedIndexChanged event gets called, next stage was to
make that button invisible but add the following code to the datagrid
ItemDataBound event...
//This highlights on mouse over - works fine!
e.Item.Attributes.Add("onmouseover",
"this.style.backgroundColor='Silver';this.style.color='white';this.style.cursor='hand'");
//this unhighlights on mouseout - works fine also!
e.Item.Attributes.Add("onmouseout",
"this.style.backgroundColor='white';this.style.color='black';this.style.cursor='hand'");
//this calls the doPostBakc function passing parameters just as the
'select' button does, but it doesnt call the SelectedIndexChanged
event :'(
e.Item.Attributes.Add("onclick","javascript:__doPostBack('" +
"dgAllPosts:" + "_ctl" + 1 + ":_ctl0','')");
Anyways, if anyone can see what I'm doing wrong, or has a better way
to achieve this, I'd love to hear from you.
Thanks chaps
James