Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > CheckBox Checked=false when checked in DataList

Thread Tools

CheckBox Checked=false when checked in DataList

Posts: n/a
Hello I have a DataList like this

<aspataList id="Questions" Runat="server">
<table border="1">
<asp:CheckBox ID="Yes" Runat="server"></asp:CheckBox>
<input type="hidden" runat="server" value='<%#
DataBinder.Eval(Container.DataItem, "I_QUESTION_ID") %>' ></input>
<%# DataBinder.Eval(Container.DataItem, "V_HEALTH_QUESTION")%>
<asp:Button id="DoThis" runat="server" text="go"></asp:Button>

in the click for the button I do this
StringBuilder hqs = new StringBuilder();
foreach(DataListItem dli in Questions.Items)
//if ( ((CheckBox)dli.Controls[1]).Checked )
if ( ((CheckBox)dli.FindControl("Yes")).Checked )
hqs.Append( ((HtmlInputHidden)dli.Controls[3]).Value+",");

The first item says checked=false even when I checked it.....
Any items?

Reply With Quote
rajeshthangarasu1983 rajeshthangarasu1983 is offline
Junior Member
Join Date: Jan 2008
Posts: 1
Solution To checkbox checked=false in datalist

Bind the data when page.ispostback is false

if( ! page.ispostback)

Comment:The problem why checkbox is showing checked status false is when u press the button, page post back occurs and datalist is populated again. So bind the data when page.ispostback is false
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
CheckBox Outside DataList & Labels Inside DataList ASP .Net 1 12-24-2006 02:28 PM
Help: Checkbox in datalist - checked status = ALWAYS FALSE! VB Programmer ASP .Net 1 04-13-2005 12:59 AM
Setting up a datalist control - Item_DataBound for a datalist in a datalist Nevyn Twyll ASP .Net 8 09-09-2004 10:13 PM
checkbox checked change event question Matthew Louden ASP .Net 2 11-18-2003 07:25 AM
Checkbox - database checkbox, if checked gives value of 1 .. how to sum ? randy Perl Misc 13 11-01-2003 05:39 AM