Click here to Skip to main content
16,012,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi to All,
I have datagridview with labels, while click any label in the gridview row then i want to check checkbox with respective row... please send me some sample code ....
Posted

1 solution

XML
1.Add Itemplate as label
and call javscript function on onclick event of label with passing id of this label.

code:

<ItemTemplate >
<asp:Label ID="lblCompany" runat="server" Text='<%# Bind("Company")%>' onClick="return FunctionName(event,this);" contentEditable="true"></asp:Label>
</ItemTemplate>


javscript:
fucntion functionname(e,ctrl)
{

//from this you can get current row index and cellindex by using this you can make

var row=ctrl.offsetParent.parentNode.rowIndex;
var cell=ctrl.offsetParent.cellIndex;

var gdv = document.getElementById('GridView1');
gdv.rows(row).cells(column number of your checkbox column).children.item(0).checked=true;

}



Or

2.you directly call javascript function on gridview click

code:

<asp:GridView ID="GridView1" runat="server" Width="80%"  onClick="return return FunctionName(event,this);" >

javscript:

fucntion functionname(e,ctrl)
{

var gdv = document.getElementById('GridView1');

//from this you can get current row index and cellindex by using this you can make

var row=ctrl.document.activeElement.parentElement.rowIndex;
var cell=ctrl.document.activeElement.cellIndex;

gdv.rows(row).cells(column number of your checkbox column).children.item(0).checked=true;

}

I hope it helps you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900