.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

GridView checkboxes problem

Posted By: pooja     Posted Date: April 09, 2010    Points:2   Category :ASP.Net
Hi frnds..


i have a gridview which is binded to a table in the database.
it has columns like Name,ID,City and EMail
i have chekboxes for selecting all rows and unselect.

i used javascript for selecting all and unselect

i used the follwoing code for that..







function selectAll(invoker)
{
// Since ASP.NET checkboxes are really HTML input elements
// let's get all the inputs
var inputElements = document.getElementsByTagName('input');

for (var i = 0 ; i < inputElements.length ; i++) {
var myElement = inputElements[i];

// Filter through the input types looking for checkboxes
if (myElement.type === "checkbox") {

// Use the invoker (our calling element) as the reference
// for our checkbox status
myElement.checked = invoker.checked;
}
}
}







. its working fine for that...

i want to javascript code for single row select.

but if i select any single row then the the EMail of that row must be displayed in the label...


i want only javascriot....

thanx in advabce

Responses
Author: Venkat             
Posted Date: April 12, 2010     Points: 5   

Hi,

<asp:TemplateColumn>
<HeaderTemplate>
<asp:CheckBox ID="ChkboxPMSelAll" runat="Server" OnClick="CheckTest('ChkboxPM',this.checked,formName)" /></HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="ChkboxPM" runat="Server" />
</ItemTemplate>
</asp:TemplateColumn>

function CheckTest (chkD,v,formname)
{
for (var i=0;i<document.forms[formname].length;i++)
{
e=document.forms[formname].elements[i];
if (e.type.indexOf('checkbox')!= -1 && e.name.indexOf(chkD) != -1 )
{
document.forms[formname].elements[i].checked=v;
}
}
}


http://forums.asp.net/t/897836.aspx

Mark As Answer if this solve your problem
Warm Regards,
Venkat


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend