Wrox Programmer Forums
|
ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 15th, 2007, 03:27 PM
Registered User
 
Join Date: May 2007
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default GridView Checkbox ItemTemplate

Hello,

Someone can help me? I have a checkbox ItemTemplate within a GridView, so I need to fire an Update action when the user click the checkbox field, the problem that I have is that I do not know How can I get or control the field checked?

Thanks a lot in advance for your help.

Angie
 
Old May 23rd, 2007, 01:53 AM
Authorized User
 
Join Date: May 2007
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to DarkForce
Default

hi angie,

can you show me how u put the checkbox inside the gridview?

thx

So long
 
Old May 30th, 2007, 07:32 AM
Registered User
 
Join Date: May 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to pavank
Default

 <asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkOne" Checked="false" runat="server"/>
</ItemTemplate>
</asp:TemplateField>


for finding checkbox is checked are not in girdview is...

GridViewRow row=gridview1.Rows[e.RowIndex];


  bool isChecked = ((CheckBox)row.FindControl("chkOne")).Checked;


u try this.









pavan
 
Old May 31st, 2007, 04:44 AM
Authorized User
 
Join Date: May 2007
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You must add button take the action of the checked items like:

protected void Button1_Click(object sender, EventArgs e)
    {
           // Select the checkboxes from the GridView control
        for (int i = 0; i < GridView2.Rows.Count; i++)
        {
            GridViewRow row = GridView2.Rows[i];



            bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

            if (isChecked)
            {// Do somtihng...}
}
}

and it will work






Similar Threads
Thread Thread Starter Forum Replies Last Post
Gridview and Checkbox krasnokojiy ASP.NET 2.0 Basics 14 February 28th, 2008 12:56 PM
Confirmation with checkbox in gridview collie Visual Studio 2005 0 October 24th, 2007 06:13 AM
Checkbox in Gridview yukijocelyn ASP.NET 2.0 Basics 0 September 24th, 2007 12:32 AM
Checkbox in GridView aliirfan84 ASP.NET 2.0 Professional 1 May 15th, 2007 03:59 PM
State of CheckBox in ItemTemplate of DataGrid bpgadhia Classic ASP Professional 1 August 19th, 2004 01:26 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.