1 Replies - 3595 Views - Last Post: 08 November 2012 - 06:21 PM Rate Topic: -----

#1 satyamisno1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 06-November 12

why checkboxes are not comming in output?

Posted 08 November 2012 - 03:41 AM

I Created a code for displaying checkboxes dynamically from SQL Server data.
and a button bellow to pass the checked values to second page in ASP.NET for jquery mobile site.
but iam not getting checkboxlist there.. why??

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace myApp
    public partial class WebForm1 : System.Web.UI.Page
        //CheckBoxList PersonList;
        protected void Page_Load(object sender, EventArgs e)
            CheckBoxList ArtistList;
            PersonList = new CheckBoxList();
            PersonList.AutoPostBack = true;
            //ArtistList.SelectedIndexChanged = new EventHandler(ArtistList.SelectedIndexChanged);
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConStr"].ConnectionString);
            SqlCommand cmd = new SqlCommand("select Name from Person_Details", con);
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            Session["PersonListviewstate"] = PersonList;
        protected void PersonList_SelectedIndexChanged(object sender, EventArgs e)
        protected void Button1_Click(object sender, EventArgs e)
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["myConStr"].ConnectionString);
            SqlCommand cmd1 = new SqlCommand("select count(*) from Person_Details", con);
            SqlDataAdapter SDA1 = new SqlDataAdapter(cmd1);
            DataSet ds1 = new DataSet();
            int num = SDA1.Fill(ds1);
            //int num= Sql(select count(*) from Person_Details);
            for (int i = 0; i < num; i++)
                string name = PersonList.SelectedItem.ToString();
                SqlCommand cmd = new SqlCommand("select * from Person_Details where Name='" + name + "'", con);
                SqlDataAdapter SDA = new SqlDataAdapter(cmd);
                DataSet ds = new DataSet();
                Session["dsPersonDetails"] = ds;


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="myApp.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=0" />
    <link rel="stylesheet" href="stylesheets/jquery.mobile-1.1.1.min.css" />
    <link rel="stylesheet" href="stylesheets/CssForMobileApp.css" />
    <style type="text/css" title="currentStyle">
        @import "stylesheets/media/css/demo_page.css";
        @import "stylesheets/media/css/header.ccss";
        @import "stylesheets/media/css/demo_table.css";
    <script type="text/javascript" src="libraries/jquery-1.8.2.min.js"> </script>
    <script type="text/javascript" src="libraries/jquery.dataTables.min.js"> </script>
    <script type="text/javascript" src="libraries/jquery.mobile-1.2.0.min.js"></script>
    <script type="text/javascript" src="libraries/JavascriptForMobileApp.js"></script>
    <form id="form1" runat="server">
        <div data-role="page" id="CheckboxListPage">
            <div id="header" data-theme="b" data-role="header">
                    List of Persons
            <div data-role="content" data-theme="a" data-mini="true">
                    <asp:CheckBoxList ID="PersonList" 
                        onselectedIndexChanged="PersonList_SelectedIndexChanged" DataSourceID="SqlDataSource1">
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:myConStr %>" 
                        SelectCommand="SELECT [name] FROM [Person_Details]">
                    <br />
                    <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

Is This A Good Question/Topic? 0
  • +

Replies To: why checkboxes are not comming in output?

#2 Nakor   User is offline

  • Professional Lurker
  • member icon

Reputation: 448
  • View blog
  • Posts: 1,504
  • Joined: 28-April 09

Re: why checkboxes are not comming in output?

Posted 08 November 2012 - 06:21 PM

i'm not sure I completely understand your question. Is the checkbox list not showing up on the first page or the second page? Are you getting any error messages? What is it doing compared to what you think it should be doing?

And is there a reason you're trying to load the PersonList control using a SqlDataSource and using code in your code-behind file? Not to mention it looks like you're trying to add a PersonList control to a page that already has a PersonList control.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1