Edit Datagrid row On Double Click
-
Hi Guys, I like to edit datagrid row on double click event in c#. Any suggestions ? Thanks in Advance.
-
you could use the client side event ondblclick and fake that to call the javascript __doPostBack function and then handle that on the server side ... might be a bit hary though :)
Wally Atkins
Newport News, VA, USA -
Well, it really depends on what functionality you are trying to provide here ... but here is my general thought: When the datagrid is databound try calling a function similar to this ...
private void AddDoubleClickHandler(DataGrid dg, string ctl) {
int count = dg.Items.Count;
for (int i = 0; i < count; i++) {
dg.Items[i].Attributes.Add("ondblclick", "__doPostBack('" + dg.Items[i].UniqueID.Replace(":","$") + "$_ctl" + ctl + "','');");
}
}which takes in a datagrid and will add to each row a client side ondblclick event ... which in turn will try to use the __doPostBack function to mimic a control being used. From there you could do a bunch of stuff ... if this seems a bit confusing or a stretch on what you are trying to do I can understand. But, hopefully it will get you heading in the direction you want to go ...
Wally Atkins
Newport News, VA, USA -
Well, it really depends on what functionality you are trying to provide here ... but here is my general thought: When the datagrid is databound try calling a function similar to this ...
private void AddDoubleClickHandler(DataGrid dg, string ctl) {
int count = dg.Items.Count;
for (int i = 0; i < count; i++) {
dg.Items[i].Attributes.Add("ondblclick", "__doPostBack('" + dg.Items[i].UniqueID.Replace(":","$") + "$_ctl" + ctl + "','');");
}
}which takes in a datagrid and will add to each row a client side ondblclick event ... which in turn will try to use the __doPostBack function to mimic a control being used. From there you could do a bunch of stuff ... if this seems a bit confusing or a stretch on what you are trying to do I can understand. But, hopefully it will get you heading in the direction you want to go ...
Wally Atkins
Newport News, VA, USA -
Thanks for Suggestion. Actually i try to edit my datagrid any rows any columns when ever i double click this column. same like when we use edit command button on each row. Thanks