Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

CheckBox Checked=false when checked in DataList

 
 
yurps
Guest
Posts: n/a
 
      01-28-2005
Hello I have a DataList like this

<aspataList id="Questions" Runat="server">
<ItemTemplate>
<table border="1">
<tr>
<td>
<asp:CheckBox ID="Yes" Runat="server"></asp:CheckBox>
<input type="hidden" runat="server" value='<%#
DataBinder.Eval(Container.DataItem, "I_QUESTION_ID") %>' ></input>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "V_HEALTH_QUESTION")%>
</td>
</tr>
</table>
</ItemTemplate>
</aspataList>
<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
 
      02-29-2008
Solution To checkbox checked=false in datalist

Bind the data when page.ispostback is false

if( ! page.ispostback)
{
bindyourdata();
}


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
 
 
 
Reply

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 rn5a@rediffmail.com 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



Advertisments