Click here to Skip to main content
15,899,124 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: how to get the count Pin
Anjani Poornima27-May-09 19:43
Anjani Poornima27-May-09 19:43 
GeneralRe: how to get the count Pin
padmanabhan N27-May-09 19:58
padmanabhan N27-May-09 19:58 
GeneralRe: how to get the count Pin
Anjani Poornima27-May-09 20:14
Anjani Poornima27-May-09 20:14 
GeneralRe: how to get the count Pin
padmanabhan N27-May-09 20:19
padmanabhan N27-May-09 20:19 
GeneralRe: this is the sample which i did for you... this is working fine... just copy and paste and check Pin
padmanabhan N27-May-09 20:34
padmanabhan N27-May-09 20:34 
GeneralRe: how to get the count Pin
Anjani Poornima27-May-09 20:48
Anjani Poornima27-May-09 20:48 
GeneralRe: how to get the count Pin
Anjani Poornima27-May-09 21:45
Anjani Poornima27-May-09 21:45 
GeneralRe: how to get the count [modified] Pin
padmanabhan N27-May-09 22:04
padmanabhan N27-May-09 22:04 
//java script

var TotalChkBx;
var Counter;

window.onload = function()
{
TotalChkBx = parseInt('<%= this.GridView1.Rows.Count %>');
Counter = 0;
}

function SelectAll(CheckBox)
{
var TargetBaseControl = document.getElementById('<%= this.GridView1.ClientID %>');
var TargetChildControl = "CheckBox1";
var Inputs = TargetBaseControl.getElementsByTagName("input");
for(var n = 0; n &lt; Inputs.length; ++n)
if(Inputs[n].type == 'checkbox' && Inputs[n].id.indexOf(TargetChildControl,0) >= 0)
Inputs[n].checked = CheckBox.checked;
Counter = CheckBox.checked ? TotalChkBx : 0;
if(Counter !=0)
document.getElementById('Label1').innerText = Counter;
else
document.getElementById('Label1').innerText = "no records selected";
}


//in your aspx
<headertemplate>
<asp:checkbox id="CheckBox2" runat="server" onclick="javascript:SelectAll(this);">



//your aspx.cs page
protected void CheckBox1_CheckedChanged1(object sender, EventArgs e)
{
int count = 0;
for (int i = 0; i < GridView1.Rows.Count; i++)
{
GridViewRow rows = GridView1.Rows[i];
bool ischeck = ((CheckBox)rows.FindControl("CheckBox1")).Checked;
if (ischeck)
{
count = count+1;
}
if (count != 0)
{
Label1.Text = Convert.ToString(count);
}
else
{
Label1.Text = "no records selected";
}
}
}

Padmanabhan

modified on Thursday, May 28, 2009 4:20 AM

GeneralRe: how to get the count Pin
Anjani Poornima27-May-09 22:54
Anjani Poornima27-May-09 22:54 
GeneralRe: how to get the count Pin
padmanabhan N27-May-09 22:59
padmanabhan N27-May-09 22:59 
Questionusing checkbox in gridview Pin
Anjani Poornima27-May-09 1:54
Anjani Poornima27-May-09 1:54 
AnswerRe: using checkbox in gridview [modified] Pin
padmanabhan N27-May-09 1:59
padmanabhan N27-May-09 1:59 
Questionwant to use rss Pin
jainiraj27-May-09 1:48
jainiraj27-May-09 1:48 
AnswerRe: want to use rss Pin
Aman Bhullar27-May-09 2:46
Aman Bhullar27-May-09 2:46 
GeneralRe: want to use rss Pin
jainiraj27-May-09 3:54
jainiraj27-May-09 3:54 
GeneralRe: want to use rss Pin
Aman Bhullar28-May-09 2:09
Aman Bhullar28-May-09 2:09 
QuestionCommandArgument='&lt;%# Bind("ID")&gt;' Pin
Uma J27-May-09 1:41
Uma J27-May-09 1:41 
AnswerRe: CommandArgument='&lt;%# Bind("ID")&gt;' Pin
padmanabhan N27-May-09 1:48
padmanabhan N27-May-09 1:48 
Questionhow to redirect to Other page when after click the ok button Pin
sanmbk27-May-09 0:51
sanmbk27-May-09 0:51 
AnswerRe: how to redirect to Other page when after click the ok button Pin
padmanabhan N27-May-09 1:05
padmanabhan N27-May-09 1:05 
AnswerRe: how to redirect to Other page when after click the ok button Pin
Manas Bhardwaj27-May-09 1:05
professionalManas Bhardwaj27-May-09 1:05 
QuestionASP.NET Pin
sanmbk27-May-09 0:50
sanmbk27-May-09 0:50 
AnswerRe: ASP.NET Pin
padmanabhan N27-May-09 0:57
padmanabhan N27-May-09 0:57 
QuestionProblem using crystal report viewer Pin
CrazyCoder2627-May-09 0:45
CrazyCoder2627-May-09 0:45 
AnswerRe: Problem using crystal report viewer Pin
saransh3212-Jun-09 20:59
saransh3212-Jun-09 20:59 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.