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

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Gridview Checkbox

Posted By:      Posted Date: August 25, 2010    Points: 0   Category :ASP.Net

in my gridview I have 5 column, that include checkbox, I want to check only one checkbox in a row. How can do it? Can anybody help me? Thanks.

 <asp:TemplateField HeaderText="1">
         <asp:CheckBox ID="chk1" runat="server" />
  <asp:TemplateField HeaderText="2">
        <asp:CheckBox ID="chk2" runat="server" />
   <asp:TemplateField HeaderText="3">
        <asp:CheckBox ID="chk3" runat="server" />
    <asp:TemplateField HeaderText="4">

View Complete Post

More Related Resource Links

AJAX GridView Checkbox Select All in ASP.Net

In the previous article GridView Select Multiple Rows you learnt the multiple row selection in GridView control. Here you will get the C# code sample to select all the gridview rows using single checkbox server control. You can highlight the selected rows with different color and Font state Bold. If you want to use the selection values on different ASP.Net

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Gridview setup:

jQuery: Highlight Gridview Rows with Checkbox

Im learning and experimenting with jQuery and ASP.NET. Below is a simple solution I created to highlight rows in a gridview by clicking on a checkbox next to the row.

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

validate the selection of atleast one checkbox in the gridview using javascript


 i have a gridview with a checkbox in the templatefield as given  below,

<asp:GridView runat="server" ID="gvAsgnHw"  AutoGenerateColumns="False"   >
        <asp:CheckBox id="cbAsgnHwGrid"   runat="server" /> </ItemTemplate></asp:TemplateField>

         <asp:BoundField DataField="Resource_id" HeaderText="Resource ID"/>
        <asp:BoundField DataField="Resource_name" HeaderText="Hardware Name" />

I want to check the selection of atleast one checkbox on a button click using javascript.
pls help

Templatefield CheckBox in gridview acting strange

I have an ASP.NET page that contains a gridview. I have to create columns dynamically based on a datatable, some field type info and some header texts. I do that by creating templates. It created the grid fine and all looks good, however when i click a checkbox and the checkedchanged event fires then something odd happens The first time i click its fine and i get the expected values in the event But the second time then the event gets fired with the values from the first time and then again with the values from the checkbox that i actually clicked.. The third time the event gets fired 3 times, first 2 times with the old values and the third with the correct value. And it just keeps going like that Furthermore Let us say i have 10 checkboxes that are checked when i uncheck one the checkedchanged event fires but if i check it again the event doesnt fire and also if i have unchecked 3 checkboxes(and get the extra events) then if i check one of them again i get 2 checked changed events fired for the ones that are still unchecked but no event gets fired for the box that i checked  so now im just baffled   See pastebin link below for code: http://pastebin.com/stcwqsYa 

Gridview Checkbox Delete

this is a duplicate of my other post. The reason for this is I can't view my first topic about this. I tried in my laptop, pc, and also my friend's pc but I can't view the topic. It slows down the browser and will hang.So here it is.My gridview is being generated at runtime by a dataset. My first column is a template field with checkbox, how to delete a selected row? C# please.This is my code but it doesn't work.protected void DeleteSelected_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { CheckBox cb = (CheckBox)row.FindControl("RegistrySelector"); { if(cb.Checked) { string id = GridView1.DataKeys[row.RowIndex].Value.ToString(); string del = "delete from EnrollTbl where Register_ID="+id; da = new SqlDataAdapter(del,con); ds = new DataSet(); ds.Clear(); da.Fill(ds); GridView1.DataSource = ds; GridView1.DataBind(); } } }

disable autopostback of checkbox inside of GridView during SelectedIndexChanged of ListView

Hi, I hope my question is clear: I have a checkbox placed inside a gridview: <GridView><asp:TemplateField HeaderText="Driver">   <ItemTemplate>       <asp:CheckBox ID="CheckBoxDriver" AutoPostBack="true" OnCheckedChanged="GridView_Persons_SelectedIndexChanged" ValidationGroup='<%# Eval("ID") + "-" +((GridViewRow)Container).RowIndex %>' CssClass="CXDriver" runat="server" Checked='false' />   </ItemTemplate>       </GridView> For example: A listViewItem 1 has 3 drivers are checked, A listViewItem 2 has 2 drivers are checked. Therefore, if changing the selectedIndex of the list, the checkbox indexChanged event will be fired. How could I disable the autopostback of the checkbox during the listview item changed. Thanks in advance

Checkbox checked changed event inside gridview

Hi All, In my gridview there are 8 checkboxex in each row : 'Sunday' to 'Saturday' and one for 'All'. If 'All' is checked in a particular row, all other checkboxes in that row should be checked instantly, and viserversa. Can i do this in checkbox checked_changed event, if so how do i access the current row of the gridview in the checked changed event? Thanks in advance

Get selected row value based on checkbox selected in gridview using jquery

Hi ,    i am having gridview with two columns.one column contains checkboxes and another column contains Name.i have given UserId to DataKeyNames in gridview.Now i will check some checkboxes in gridview and click on button GetData. whenver i click on button GetData i need to get datakey values of all the gridview rows whatever checked in gridview using JQUERYPlease help me i am new to JQUery

Inserting Records Based on Checkbox Selection in a Gridview

Using checkboxes, can the row of record(s) be inserted into a database? I am populating a Gridview. Done. A checkbox field has been added, when the user selects one or more rows, a submit button (which is not working) needs to inserting those records into a table. The insert statment will work outside of the page but is not working using the scenario I jut described. Is this task as I have outlined doable? txs Ayomide

gridview checkbox sorting not working

Hi All,I have a grid view which populates data just for viewing purpose(report) . One field shows the Active/inactive status for which I am showing a checkbox..if data in database is 1 then the checkbox will be checked otherwise it'll not be checked. This field is inactive so that the User does not check/uncheck it. The issue is that this field cannot be sorted. All the fields in the gridview are being sorted. Below is the code for the checkbox column. <asp:TemplateField HeaderText="InActive" SortExpression="Inactive"><HeaderTemplate ><asp:Label ID="lblStat" CssClass="copyLabel" Text="Inactive" CommandArgument="Inactive"                    runat="server"></asp:Label></HeaderTemplate> <ItemTemplate><asp:CheckBox runat="server" ID="chkStatus" Enabled="false"/></ItemTemplate></asp:TemplateField>I have given AllowSorting="True" in the gridview properties. The code in the gridview sorting event works fine for all other columns except the checkbox column. Please help and suggest some scenarios/links so that I can achieve sorting for the checkbox column also.Thanks in advance.

gridview and checkbox colunm

I have a gridview were one of the colunms has a checkbox for deleting that row. When the user open the page the delete button is set to enable = false. If the user checks one box the delete imagebutton is disable = false. That works, now I need to add Javascript to enable the Delete button if the user selects checkAll, how do I do that?

How to get Checkbox value created at runtime above gridview header


I have creted a checkbox for each column of grid at the top of the header in row created event. I need to check wheather checkbox is checked after button click event.

//Build custom header.

                GridView oGridView = (GridView)sender;
                GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert);
                TableCell oTableCell = new TableCell();

                //Add Staff_ID
                CheckBox chkStaffID = new CheckBox();
                chkStaffID.ID = "chkStaff_ID";
                chkStaffID.Text = "Hide";
                chkStaffID.CheckedChanged += new System.EventHandler(chkStaffID_CheckedChanged);

Dynamically adding a checkbox to a gridview in a webpart


I have a webpart with a gridview that I would like to add a checkbox column to. I have read through a few articles but have not found one that actually works. Any help would be greatly appreciated.


Luis R. Lebron

Gridview CheckBox Persist in Paging


I Use a Gridview which Contains Lots OF Records with Paging...

 I have a checkBox Column ,i want to persist state of Checked Checkboxes while Moving From One Page To Another.

Example:-Suppose a Check a Checkbox on First Page 6th Row and Move to 2nd Page and Check 10th Row,and Then when i naviagte back to 1st Page i want to Show the 6th Row Checked in First Page and Viceversa... 


Gridview CheckBox Persist in Paging


Related to this thread: Gridview CheckBox Persist in Paging

Is there any other option than ViewState or Session to save the datatable ? 

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

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