Click here to Skip to main content
15,925,081 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionDatalist paging Error Pin
mohd faiz15-Nov-06 2:21
mohd faiz15-Nov-06 2:21 
AnswerRe: Datalist paging Error Pin
Paddy Boyd15-Nov-06 2:51
Paddy Boyd15-Nov-06 2:51 
QuestionStrings not updated in gridview Pin
kascakm15-Nov-06 1:36
kascakm15-Nov-06 1:36 
AnswerRe: Strings not updated in gridview Pin
kascakm15-Nov-06 1:52
kascakm15-Nov-06 1:52 
QuestionHow manage paging in gridview if its datasource is datareader Pin
neetusharmain15-Nov-06 1:35
neetusharmain15-Nov-06 1:35 
AnswerRe: How manage paging in gridview if its datasource is datareader Pin
hariom parmar17-Nov-09 21:50
hariom parmar17-Nov-09 21:50 
Questiondeleteing rows in a datagrid Pin
yuvachandra15-Nov-06 1:34
yuvachandra15-Nov-06 1:34 
AnswerRe: deleteing rows in a datagrid Pin
Grapes-R-Fun15-Nov-06 5:52
Grapes-R-Fun15-Nov-06 5:52 
You just got lucky! Put the following javascript within the <head>...</head> tags in your web form:

<script language="javascript" type="text/javascript">
function SelectAllCheckboxes(spanChk)
{

// Added as ASPX uses SPAN for checkbox
var oItem = spanChk.children;
var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];
xState=theBox.checked;

elm=theBox.form.elements;
for(i=0;i<elm.length;i++)
if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
{
if(elm[i].checked!=xState)
elm[i].click();
}
}
</script>


Then, you will have to add templated checkbox field in your dGridView, and Im hoping you know how to do that. Once you make that templated field, drag a checkbox in the ItemTemplate AND HeaderTemplate. Name the HeaderTemplate's checkbox "chkAll" and name the ItemTemplate's checkbox "yourCheckBox". Then follow the below schema for the onClick event:

<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:CheckBox id="yourCheckBox" runat="server" />
</ItemTemplate>
<HeaderTemplate>Select All
<asp:CheckBox onclick="javascript:SelectAllCheckboxes(this);" id="chkAll" runat="server">
</asp:CheckBox>
</HeaderTemplate>
</asp:TemplateField>

To process the checked rows through an event handler, put in a button and get the onClick event handler ready, then do as below:

protected void yourButton_Click(object sender, EventArgs e)
{
yourObject = new yourClass();
int count = GridView1.Rows.Count;
for (int i = 0; i < count; i++)
{
//access each CheckBox from the TemplateField
CheckBox cb = (CheckBox)(GridView1.Rows[i].FindControl("yourCheckBox"));

//If it's checked, process it...
if (cb.Checked)
{
//do your thing!
yourObject.doWhatYouDo(GridView1.Rows[i].Cells[2].Text); //the Cells[2] points to the data within third column, it can be anything
}
}
yourObject.Dispose();
}

Let me know if you need help Smile | :)

Nila
QuestionHow to change encoding style in webservice Pin
Tiger45615-Nov-06 1:31
Tiger45615-Nov-06 1:31 
QuestionPanel probelm [modified] Pin
Kissy1615-Nov-06 1:23
Kissy1615-Nov-06 1:23 
Questionhelp for enabled property Pin
vamsimohan2115-Nov-06 1:12
vamsimohan2115-Nov-06 1:12 
AnswerRe: help for enabled property Pin
ennaj15-Nov-06 10:28
ennaj15-Nov-06 10:28 
QuestionOutputCache dynamically loaded UserControl. Pin
theJazzyBrain15-Nov-06 1:11
theJazzyBrain15-Nov-06 1:11 
AnswerRe: OutputCache dynamically loaded UserControl. Pin
l0kke15-Nov-06 4:09
l0kke15-Nov-06 4:09 
Questionneed help in JS the application is using Atlas Pin
varuni6515-Nov-06 1:11
varuni6515-Nov-06 1:11 
QuestionOnly refreshing the part of a page Pin
Imtiaz Murtaza15-Nov-06 1:10
Imtiaz Murtaza15-Nov-06 1:10 
AnswerRe: Only refreshing the part of a page Pin
l0kke15-Nov-06 4:19
l0kke15-Nov-06 4:19 
AnswerRe: Only refreshing the part of a page Pin
ednrgc15-Nov-06 4:53
ednrgc15-Nov-06 4:53 
QuestionFill form fields in microsoft word doc using asp.net Pin
vijeta_r15-Nov-06 1:07
vijeta_r15-Nov-06 1:07 
Questiondropdownlist overlaps the jscript menu Pin
Amit Kushwaha15-Nov-06 1:00
Amit Kushwaha15-Nov-06 1:00 
AnswerRe: dropdownlist overlaps the jscript menu Pin
RichardGrimmer15-Nov-06 1:12
RichardGrimmer15-Nov-06 1:12 
AnswerRe: dropdownlist overlaps the jscript menu Pin
Paddy Boyd15-Nov-06 1:17
Paddy Boyd15-Nov-06 1:17 
QuestionSending email with ASP.NET 2.0 Pin
shapper15-Nov-06 0:29
shapper15-Nov-06 0:29 
QuestionGenerate GUID using 2 digit State Code Pin
AmitChampaneri15-Nov-06 0:16
AmitChampaneri15-Nov-06 0:16 
AnswerRe: Generate GUID using 2 digit State Code Pin
l0kke15-Nov-06 4:38
l0kke15-Nov-06 4:38 

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.