[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.
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.
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.
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!
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. :afrog:
PS: I'm partially psychic.