select all row one more than one column

 

 I add checkbox control in header template to select all row. if one column have select all propert there is no problem. However, when add second column and add select all another column there occur a problem. When ı select first column select all checkbox, second colum checkbox checked. How can ı solve this problem. 

 

 

 

 

0
Ozo
2/25/2009 8:40:09 AM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
692 Views

Similar Articles

[PageSpeed] 31

 Hi,

Following links will help you out ...

http://programming.top54u.com/post/ASP-Net-GridView-Checkbox-Select-All-using-C-sharp.aspx

http://aspnet.4guysfromrolla.com/articles/053106-1.aspx

http://aspnet.4guysfromrolla.com/articles/052406-1.aspx

 


Regards
Amit
0
thakur_amit
2/25/2009 12:06:42 PM

Hi Ozo,

I wrote a sample ,

<asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" DataKeyNames="countryid"

DataSourceID="SqlDataSource3" OnRowDataBound="GridView2_RowDataBound" Width="137px" OnPreRender="GridView2_PreRender">

<Columns>

<asp:TemplateField>

<HeaderTemplate>

<asp:CheckBox ID="chkH1" runat="server" />

</HeaderTemplate>

<ItemTemplate>

<asp:CheckBox ID="chkItem1" runat="server" />

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField>

<HeaderTemplate>

<asp:CheckBox ID="chkH2" runat="server" />

</HeaderTemplate>

<ItemTemplate>

<asp:CheckBox ID="chkItem2" runat="server" />

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

<script>

function abccheckorcancelall(self)

{

if(self.checked == true)

{

for(var i = 0 ;i<err.length;i++)

{

var temp = document.getElementById(err[i]);temp.checked = true;

}

}

else

{

for(var i = 0 ;i<err.length;i++)

{

var temp = document.getElementById(err[i]);temp.checked = false;

}

}

}

 

function abccheckorcancelall2(self)

{

if(self.checked == true)

{

for(var i = 0 ;i<err2.length;i++)

{

var temp = document.getElementById(err2[i]);temp.checked = true;

}

}

else

{

for(var i = 0 ;i<err2.length;i++)

{

var temp = document.getElementById(err2[i]);temp.checked = false;

}

}

}

</script>

 

 

 

    string err = "";
    string err2 = "";
    protected void GridView2_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            CheckBox chk1 = e.Row.FindControl("chkH1") as CheckBox;
            CheckBox chk2 = e.Row.FindControl("chkH2") as CheckBox;
            chk1.Attributes.Add("onclick", "abccheckorcancelall(this)");
            chk2.Attributes.Add("onclick", "abccheckorcancelall2(this)");
        }
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            CheckBox ch1 = e.Row.FindControl("chkItem1") as CheckBox;
            CheckBox ch2 = e.Row.FindControl("chkItem2") as CheckBox;
            err += "'" + ch1.ClientID + "',";
            err2 += "'" + ch2.ClientID + "',";
        }
    }
    protected void GridView2_PreRender(object sender, EventArgs e)
    {
        this.ClientScript.RegisterArrayDeclaration("err", err.Substring(0, err.Length - 1));
        this.ClientScript.RegisterArrayDeclaration("err2", err2.Substring(0, err2.Length - 1));
    }

 

 



Samu Zhang
Microsoft Online Community Support

Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question.
0
Samu
2/27/2009 6:16:30 AM
Reply:

Similar Artilces:

SQL: mutiple rows one column to multiple columns one row
In InfoMaker SQL can you take a table with multiple rows for the same key and take a column from the rows and create mutiple columns with one report line with the key(no duplicate keys) on a report? For example Table books (key) (book title) 123 misery 123 titanic 123 roots 456 war 456 1984 456 giant The report I need would look like this Key title1 title2 title 3 123 misery titanic roots 456 war 1984 giant Thanks in advance. -- Kaye Hendry HealthInsight email:kaye.hendry@healthinsight.org ...

selecting one row and inserting it into another table one by one
i ve a table named "Employee" in wh i ve fields "Emp_Id","Name" and "Email". i want to select each employee "Emp_Id" one by one from "Employee" table and insert it into another table named "Concerned_Department". like if i ve three rows in "Employee" table with "Emp_Id" 1,2 and 3 respectively,in this case i want to first select "Emp_Id"=1 then "Emp_id"=2 and lastly "Emp_id"=3 and insert them into "Concerned_Department"table.  after that the process star...

Accessing one column in one row
Every thing I have researched on accessing data is to put it into a multi row and multi column control.  If you are already using a sqldatasource to fill a listbox, how can you use the same sqldatasource to obtain a single column out of a single row in the same database?  The rows contain an identy column and only one row in the database has a specific identy.  The row has three columns.  The first column is "nvchar" and I want to put its contents into a textbox.text.  I tried setting the select parameter to the desired identy ...

Refering to a table with one column and one row
Hi all, I wish to set a reference date for age calculations in various places. My thought was to have a table with one column and one row, with the date, say 2007/04/01(yyyy/mm/dd) Then I would like to calculate ages as on that date with a computed column. How does one link the tables? I tried it with a cross join on a simple test table. I suppose a cross join is OK as there is only one row? John, In this case, the cross join is fine. Another possibility would be to use a subselec in the places where you want to use the valuet, i. e. to use (select "date" fro...

one select gridview row at one time
hi, How can change this below code this code selecte multi row select I want to select at one time one row.means If i will select a row from my gridview at that time if i will select another row at that time previous row should be unselect and color change.and then after i will click a button then select row fields data send to diffrent textboxes.how can i solve this problem. <script language ="javascript1.1" type="text/javascript"> document.body.style.cursor = 'pointer'; var oldColor = ''; function ChangeRowColor(rowID) { ...

want to call one c#.net function in one user control from another user control
hi i have two user controls info.ascx and personal.ascx i have a function like in info.ascx i have a function like showdetails() {   } now i want to access this function from personal.ascx can i do this ? thanks in advance. shwetaThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path  you should better create a class where you will define the "functions" that you need in both files. declare "static" the function and call it like nameofclass.nameoffunction In a web project you can...

Gridview paging enabled. Has checkbox to select the row . If user select the checkbox on one page and move to 2nd page to select the rows there also to export the selected rows to excel. But doing so
HiI am using Gridview and that has paging enabled. Using checkbox to select the particular row of the gridview to export the selected rows to the excel . Everything is working fine except for one case.Let user selected the "check" box for, five rows which user would like to export to excel (two of rows on page 1 of results and 3 of them on page 2 of results), however it only exports the 3 row details from page 2, because it seems to de-select the 2 rows from page 1 when I move to page 2 and vice versa. The code i am using is as :protected void BtnExcel_Click(object sender, EventArg...

One to Many to One to One
I have a kinda small problem; if someone could help me that' would be niceTo keep things simplier, allow me to give the following exampleI have two tables one-to-many relationship,table1: itemtable2: itemhistoryitem has many itemhistorybasically i want retrieve all the records in 'item' sorted by 'name', along with ONE "latest" itemhistory" (date). If there aren't any historyhistory for a particular 'item', just allow null values. egcreate table #item(itemid int, name varchar(10))create table #itemhistory(itemhistoryid int, itemid int, date...

One-to-One or Many-to-One?
 Hi Friends,I've made huge database for Learning Management Systems which has around 30 - 40 tables.I was checking all the relationships between tables and everything seems fine and well defined. But, it's 4:22 AM here and I'm bit sleepy but I was thinking which of the following relationship is true between the following two tables:Table1: tbl_users (PK username, password, name, surname, email, address1, address2, phNumb)Table2: tbl_testAttempts (PK Id, username, testId, attempt, timeStart, timeEnd)As you see, the Primary key of tbl_users is foreign key in tbl_testAttempts. ...

Trying to enter more than one selected value into one column in the database.
Hi i am trying to enter more than one value into my constructor field in my database, at the moment when the values are entered into the database through the front end, they appear in the database as seperate records however they have the same ID,  the only thing that changes is are the data in the fields which i want in just one. This is the part of the stored procedure I am sure is causing this to happen; IF @Access_Right_ID=8  or @Access_Right_ID=3  or @Access_Right_ID=9   BEGIN     DECLARE @Delimiter char(1)     ...

How to read a dataset one row by one row?
I know you can use DataSet after close sql connection. I want to something after getting dataset, read from one row by one row, just like while datareader.read() Can I read dataset just like this? Thanks in advance! Justin Is this what you're looking for (from the Tips and Tricks Section of ASPNet101.com):http://aspnet101.com/aspnet101/tips.aspx?id=175David WierMCP/ASPInsiderASPNet101.com - where to look first!Control Grouper - easily control properties for multiple controls with one control!Calendar Express - The Best HTML Calendar Generator on the web!(Please 'Mark as Answer&...

How to display the more than one row with items and buttons in gridview control. when i select three items at same time from categories(Fruits, Apples, Gifts). The selected items are displayed in g
Hi,when i select three items at same time from categories(Fruits, Apples, Gifts). The selected items are displayed in gridview.Here i would like to change this way "when i click more than one category at same time. it should be display selected item and button."For example: if i have to select Fruits, Apples from categories.  it should be display like 1st "row have Fruits and In 2nd row have Apples and button" in gridview.the button have some event.How can i do it? Please can anyone answer me.With kind requestThanks your query is very raw..can u details it out...Pl...

SELECT a single row with one SqlDataSource, then INSERT one of the fields into another SqlDataSource
What is the C# code I use to do this? I'm guessing it should be fairly simple, as there is only one row selected. I just need to pull out a specific field from that row and then insert that value into a different SqlDataSource.Disco Patrick writes web applications using:Visual Studio 2008ASP.NET 3.5C#SQL Server 2008 What do you mean by "insert one of the fields into another SqlDataSource"?  Do you mean you want to make use of the value as a parameter for another datasource control or that you actually want to use another SqlDataSource to insert the value into a table so...

fetching all rows one by one
i'm quite new in powerbuilder so sorry if it's a stupid question. i have to get the first colum of a table out row by row so i can do some adjustments on it is this a good solution to do that? DECLARE TempTable_cur CURSOR FOR select distinct substring(col1, 1, charindex("_", col1) - 1) from Test FETCH TempTable_cur INTO ::Table DO WHILE SQLCA.SQLCode = -1 (work on variable ::table ) FETCH next TempTable_cur INTO ::Table LOOP Johan; Why don't you use a DataWindow and turn on the "Rows As Needed" feature? It will do all this proc...

Web resources about - select all row one more than one column - asp.net.presentation-controls

United States House Select Committee on Energy Independence and Global Warming - Wikipedia, the free ...
but will work with the House standing committees with jurisdiction over climate change issues and develop recommendations on legislative proposals. ...

kotaku selects
Kotaku Selects

Facebook Testing ‘Select Ad Variations To Generate’ Option In Power Editor?
Facebook appears to be testing a new feature in Power Editor that allows users to more easily test different versions of their ads. continued… ...

Select Apple Stores offering $50 discount on iPhone + Apple Watch purchases, but may not be best deal ...
... Watch Sports when bought with new iPhones, MacRumors notes. Not only is the promo not available online but it’s also being offered in select ...

Seventh Generation Selects 72andSunny After Review
Seventh Generation has named 72andSunny, New York, to lead strategy and brand development for its home and personal care products following a ...

T-Mobile Offers $100 Discount On Select Smartphones
There’s no denying the fact that a number of people are waiting for the two biggest sales on the planet—Black Friday and Cyber Monday. As a matter ...

BMW selects two artists to create M6 GT3 art cars
Filed under: Design/Style , Motorsports , BMW , Coupe , Performance , Racing Artists Cao Fei and John Baldessari will create the 18th and 19th ...

Benghazi Select Committee Hearings, Sponsored by the Stop Hillary PAC
Hearing is underway. Anyone watching? (YouTube livestream here .) I have it on as background noise and am paying intermittent attention as the ...

Best Buy to hold pre-Black Friday sale this Saturday at select locations
... from Apple, Microsoft, Sony, Fitbit and many others. Best Buy will hold a special pre-Black Friday sale for one day only this weekend. Select ...

Boehner's Last Stand: New Select Committee To Investigate Planned Parenthood
The other select committee has worked out so well for them, and their interrogation of Cecile Richards went swimmingly, too. It stands to reason ...

Resources last updated: 11/30/2015 10:45:57 PM