Results 1 to 5 of 5

Thread: [RESOLVED] Gridview's checkbox column isn't testing checked = true

  1. #1

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,566

    Resolved [RESOLVED] Gridview's checkbox column isn't testing checked = true

    Even the things that look like they will be easy turn out to be time-consuming...

    I added a checkbox column to my grid. I checked the first row and hit a button that iterates through the rows testing if the checkbox is checked or not. It tests false.

    I've viewed two tutorials and it looks like it should be as easy as this:

    Code:
            <asp:GridView ID="gvInvoices" runat="server" AutoGenerateColumns="False">
                <Columns>
      
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox runat="server" ID="ckRow" />
                    </ItemTemplate>
                </asp:TemplateField>
    Code:
            Try
    
                For Each row In Me.gvInvoices.Rows
                    Dim ck As CheckBox = DirectCast(row.FindControl("ckRow"), CheckBox)
                    
                    If ck.Checked Then...
    I am having no trouble getting access to the checkbox, but it says ck.Checked is False.

    Does anyone have a *good* tutorial or code that works???

    Thanks.

  2. #2

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,566

    Re: Gridview's checkbox column isn't testing checked = true

    Well, I downloaded all the source for one of the tutorials I had found and it does work as-is, I just have to see what's different about the way I modified it or what else I might be missing.

  3. #3
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Gridview's checkbox column isn't testing checked = true

    Do you populate the gridview in the Page Load event? If so, are you doing the Page.IsPostBack check? Because if you repopulate the grid on every page load, the checkboxes will lose their values.

  4. #4

    Thread Starter
    PowerPoster MMock's Avatar
    Join Date
    Apr 2007
    Location
    My Mustang GT
    Posts
    4,566

    Re: Gridview's checkbox column isn't testing checked = true

    Quote Originally Posted by mendhak
    Because if you repopulate the grid on every page load, the checkboxes will lose their values.
    mendhak - of all the problems you've helped me with, this is the one of which I am most appreciative!!!!!!!

    And you know what I might be doing even without seeing my code!

    Thank you so much!

  5. #5
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [RESOLVED] Gridview's checkbox column isn't testing checked = true

    No problem, I just like it when one of your problems are resolved, you get all happy - which is what I like to see in web dev.

    PS: I'm partially psychic.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width