.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

problem to get checkbox value in gridview

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

Hai everyone, im new in asp.net

im trying to get the entire row value when click on the check box and press submit. but i seems like nothing happen.

HTML code:

 <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
            <asp:TemplateField HeaderText="Select">
            <asp:CheckBox ID="chk1" runat="server"/>

            <asp:BoundField DataField="PakejID" HeaderText="PakejID" 
                            SortExpression="PakejID" />
            <asp:BoundField DataField="Name" HeaderText="Name" 
                            SortExpression="Name" />
        <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />


button click event :

protected void Button1_Click(object sender, EventArgs e)
        StringBuilder str = new StringBuilder();

        for (int i = 0; i < GridView1.Rows.Count; i++)
            GridViewRow row = GridView1.Rows[i];
            bool isChecked = ((CheckBox)row.FindControl("chk1")).Checked;

            if (isChecked)

View Complete Post

More Related Resource Links

gridview checkbox group by problem



i am using this component http://www.agrinei.com/gridviewhelper/gridviewhelper_en.htm and it works great. The problem im facing is that i need to add a checkbox column(added dinamically) and group by that checkbox. I have added the checkbox using:

        <asp:GridView ID="GridView2" runat="server" AutoGenerateColumns="False" 
            OnSorting="GridView2_Sorting" >
                <asp:BoundField DataField="Client" HeaderText="Client" SortExpression="Client" />
                <asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
                <asp:BoundField DataField="BilledBy" HeaderText="BilledBy" SortExpression="BilledBy" />
                        <asp:CheckBox ID="Include" runat="server" Text='<%# Eval("Project") %>' />

And as specified in the link, i use this code to make the grouping:

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.

Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

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

Gridview Enable Selection Problem



I have a gridview with Enable selection and Enable Paging equals to TRUE.

I also set the PageSize of my gridview to 4 so that I only displays 4 rows per page.

The problem is when I click the pager in the bottom of my gridview, my gridview is disappearing and no records appear.

Here is code behind of my gridview:

If e.Row.RowType = DataControlRowType.DataRow Then
                e.Row.Attributes("style") = "cursor:pointer"

                e.Row.Cells(2).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(3).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(4).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(5).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))
                e.Row.Cells(6).Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender, "Select$" & e.Row.RowIndex.ToString))

Configure Datasource using gridview problem


Hi i  have one asp.net textbox control..

and one dropdownlist inside gridview itemtemplate textbox..

what my problem..?

A Textbox36 has values some thing like this A1','A2','A3

i wirte this below query in sqldatasource1 and this sqldarasource1 is binded to gridview ItemTemplate Dropdownlist..

Select ItemName from Table1 where code in (@C)

Here @C im refering to Textbox36..

It show me the record if it has one value if its multiple like A1','A2','A3 it not showing/filtering ItemName data..

Whatz the probel?

problem...i want a list item to populate all data in gridview!!!


i have a dropdownbox and a gridview

what I want is to have a list item which populates all data in a gridview.

I have tried using list item selected value=0 but to no avail.

what is the easiest way to achieve this?

Excel-like experience - gridview focus problem



I'm creating a page where people can order several items from a list without having to press "edit" and "save" in between like you normally would in a gridview. The user writes down the quantity, and finally presses a "submit" button that saves the order.

I want the user to have a windows form (or excel) like eperience, so once the user puts in the quantity and moves on to the next item, either by TAB or by clicking on the TextBox, i make some calculations without the user beeing bothered with a full refresh or having to press a buton to execute the event, so I place the controls inside an UpdatePanel and use TextBox.TextChanged. The event runs code that calculates the sum for the row (price * quantity) and shows that in a column called "Sum", and updates a label in a fixed position with the new order total ("Total").

Any ideas on how to achieve this?

Right now I use a GridView with a templatefield for the Quantity and set the TextBox.TextChanged event to fire to make the calculations. The problem is that the focus then changes.

By using SmartNavigation or the ScriptManager.SetFocus I manage to retain focus on the TextBox that executed the Postback, but the user might have moved on to a textbox far down the gridview (thus causing the postback by leaving the previo

GridView Problem


I've been asked to change an ASP.NET project to MVP Architecture - which may have something to do with what is going wrong.

I make the call through the architecture to the database which returns a dataset which I've verified is correct, (using dataset.writeXML() ) just before databinding  to the gridview.

On one page everything works as expected (plus any post backs). Another page the Page_Load works correct and the gridview is populated, but any postbacks do not work- it retains the Page_Load's data. Then on the third page the GridView never shows though databinded. In all these cases I've checked that the Dataset is good data, and made sure to DataBind().

All three use the exact same logic. Any ideas or suggestions are greatly appreicated.

Thank you for your help.

public partial class UI_Admin_manageFirms : System.Web.UI.Page, IManageFirms_Pres
    static ManageFirms_Pres presentation;

    protected void Page_Load(object sender, EventArgs e)
        if (!Page.IsPostBack)
            presentation = new ManageFirms_Pres(this);

    protected void btnSearch_Click(object sender, EventArgs e)
        string firmName = (txtFirmName.Text != string.Empty) ? txtFirmName.Text : null;

Gridview Checkbox


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">

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

Checkbox Value Problem


Hi Guys,

I have a problem with razor in a checkbox. It does not get a checked value.

Here is the code:

PageData["Title"] = "Edit Your Profile - ";

var db = Database.OpenFile("mySite.sdf");
var selectQuerySingle = "SELECT * FROM UserProfiles, webpages_Membership WHERE UserProfiles.UserId = webpages_Membership.UserId AND UserProfiles.UserId=@0 AND webpages_Membership.UserId=@0 ";
var UserId = UrlData[0];

if (UserId.IsEmpty())

var row = db.QuerySingle(selectQuerySingle, UserId);

var firstname = row.firstname;
var lastname = row.lastname;
var email = row.email;
var phone = row.phone;
var address = row.address;
var city = row.city;
var zipcode = row.zipcode;
var country = row.country;
var isconfirmed = "";

if (IsPost)

firstname = Request["firstname

gridview problem....

I am sending .aspx page and code behind page ,where what i want to do is i used RequiredFieldValidator and  ValidatorCalloutExtender  both and one link is their called AddNew. When  user hit the Addnew link and if txt_srno field is empty  then requiredfieldvalidator get fire and error message will show.please someone help me get the answer...

gridview problem

hi all asp.net developers i have a problem with gridview i want show ten record from table in the gridview at 2 column in five row. like this:------------gridview-------------record1 | record2record3 | record4record5 | record6record7 | record8record9 | record101 2 3 ...-----------------------

gridview problem

hi all asp.net developersi have a problem with gridviewi want show ten record from table in the gridview at 2 column in five row.thank you.
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