C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






checkbox in a Datagrid2 which is inside the Datagrid1


Posted Date: 29 May 2008    Resource Type: Code Snippets    Category: DataGridView

Posted By: komaladevi       Member Level: Gold
Rating:     Points: 10



Hi All,

here iam attaching the code related to datagrid
We are calling same Datagrid2 inside a Datagrid1 in each and every .There we kept the checkboxes in 2nd grid with check all option , but when we are going to select
checkall option in grid2 there it is going to check all rows of datagrid1 to be checked but it should not happened if we say check all in datagrid1-2ndrow means it should check only the all checkboxes of datagrid2 in that particular row.
I will attach the snapshot also .
For that only iam going to give this please have alook and give your comments


we need get the rowcount of 2nd and 1st grid, and should give id value to anchor tags od "CheckAll" that id should pass in the selectall() function
code behind

hdnGridcount.Value = e.Item.ItemIndex + 2 'row index value
rowCount = dsClientUsers.Tables(0).Rows.Count 'row count of 2nd grid


source code

<a id="ancselall" runat="server" visible="true" onclick="return SelectAll(id)" ><u>All</u></a> | <span class="c2" style="cursor:pointer">
<a id="ancunselall" runat="server" visible="true" onclick="return UnSelectAll(id)" ><u>None</u></a>


<asp:HiddenField id=hdnGridcount runat =server value=0 />
<asp:HiddenField id=hdnGrid2count runat =server value=0 />
<asp:HiddenField id=hdnGrid3count runat =server value=0 />





here is the javascript code

function SelectAll(id)
{ var chk;
var intLength;
var intgrid1index;
var intgrid2index;
var intIndex;
var chkName;
var strCnt;
var checkid;
var intgrid1;
var intgrid2;
var str;
var intid ;
var selectallid = id;
intgrid1index = selectallid.substring(18,20);//depends on the id which you are giving to datagrid
intgrid2index = selectallid.substring(40,42);//depends on the id which you are giving to datagrid
intgrid2index++;
intIndex = document.all["hdnGridcount"].value;
strCnt = document.all["hdnGrid2count"].value;
intgrid1 = 'dgrdDefineGrps$ctl' + intgrid1index;
intgrid2 = '$dgrdClientUsers$ctl0'+ intgrid2index;
intLength = document.frmDefineGroups.length;
for(j=0;j for(i=0;i if(document.frmDefineGroups.elements[i].name == intgrid1 + intgrid2 +'$chkClient')
{
var chk;
chk = document.frmDefineGroups.elements[i];
if(document.frmDefineGroups.elements[i].type == "checkbox")
{
chk.checked=true;
}
else
{
chk.checked=false;
}
}
}
intgrid2index++;
if(intgrid2index>9)
{
intgrid2 = '$dgrdClientUsers$ctl'+ intgrid2index;
}
else
{
intgrid2 = '$dgrdClientUsers$ctl0'+ intgrid2index;
}
}
return true;
}
function UnSelectAll(id)
{ var chk;
var intLength;
var intgrid1index;
var intgrid2index;
var intIndex;
var chkName;
var strCnt;
var checkid;
var intgrid1;
var intgrid2;
var str;
var intid ;
var selectallid = id;
intgrid1index = selectallid.substring(18,20);
intgrid2index = selectallid.substring(40,42);
intgrid2index++;
intIndex = document.all["hdnGridcount"].value;
strCnt = document.all["hdnGrid2count"].value;
intgrid1 = 'dgrdDefineGrps$ctl' + intgrid1index;
intgrid2 = '$dgrdClientUsers$ctl0'+ intgrid2index;
intLength = document.frmDefineGroups.length;
for(j=0;j for(i=0;i if(document.frmDefineGroups.elements[i].name == intgrid1 + intgrid2 +'$chkClient')
{
var chk;
chk = document.frmDefineGroups.elements[i];
if(document.frmDefineGroups.elements[i].type == "checkbox")
{
chk.checked=false;
}
else
{
chk.checked=true;
}
}
}
intgrid2index++;
if(intgrid2index>9)
{
intgrid2 = '$dgrdClientUsers$ctl'+ intgrid2index;
}
else
{
intgrid2 = '$dgrdClientUsers$ctl0'+ intgrid2index;
}
}
return true;
}




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to Add a Row in a table Dynamically
Previous Resource: Dynamic creation of datagrid columns in Datagrid using a vb template
Return to Discussion Resource Index
Post New Resource
Category: DataGridView


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

masks masks masks

Contact Us    Privacy Policy    Terms Of Use