RE: checkboxcontrol does not work
- From: "Sonu Kapoor" <SonuKapoor@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 15 Jun 2005 06:27:03 -0700
Is the ViewState of the control/page maybe disabled?
--
Sonu Kapoor - [MCP]
ASP.NET Moderator
WebSite: http://www.Kapoorsolutions.com
Blog: http://www.Kapoorsolutions.com/blog/
ASP.NET News: http://www.Kapoorsolutions.com/reblogger/
"Jimmy" wrote:
> Hi,
>
> If i check my checkbox then it never returns true in the code below:
> code:
> private void Page_Load(object sender, System.EventArgs e)
>
> {
> // Put user code to initialize the page here
>
> string[] ar = new string[]{"jack","jill"};
> DataList1.DataSource=ar;
> DataList1.DataBind();
> }
>
> private void Button2_Click(object sender, System.EventArgs e)
> {
>
> int i=0;
> foreach(DataListItem item in DataList1.Items )
> {
> i+=1;
> if (((CheckBox)item.FindControl("ChkBox1")).Checked)
> {
> //never comes here even if you check chkbox!!!
> Label1.Text+="row " + i.ToString() + " is checked" +"<br>";
> }
> else
> {
> Label1.Text+="row " + i.ToString() + " is NOT checked"+"<br>";
> }
>
> }
>
> }
>
> page:
> <asp:label id="Label1" style="Z-INDEX: 102; LEFT: 64px; POSITION: absolute;
> TOP: 208px" runat="server"
> Height="32px" Width="224px">Label</asp:label><asp:datalist
> id="DataList1" style="Z-INDEX:
>
> 103; LEFT: 72px; POSITION: absolute; TOP: 8px" runat="server"
> Height="200px" Width="360px">
> <ItemTemplate>
> <asp:CheckBox id="ChkBox1" runat="server"></asp:CheckBox>
> <asp:Label text='<%# Container.DataItem %>' Runat=server>
> </asp:Label>
> </ItemTemplate>
> </asp:datalist>
> <asp:Button id="Button2" style="Z-INDEX: 104; LEFT: 320px; POSITION:
> absolute; TOP: 208px"
>
> runat="server"
> Text="Button"></asp:Button>
>
>
>
.
- References:
- checkboxcontrol does not work
- From: Jimmy
- checkboxcontrol does not work
- Prev by Date: RE: when to use usercontrol, when not to use?
- Next by Date: RE: Cannot display Custom Error Page
- Previous by thread: checkboxcontrol does not work
- Next by thread: adding query string to request
- Index(es):