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??
WebForm1.aspx.cs
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);
con.Open();
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
PersonList.Items.Add(dr[0].ToString());
}
dr.Close();
con.Close();
Page.Form.Controls.Add(PersonList);
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);
con.Open();
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);
//con.Open();
SqlDataAdapter SDA = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
SDA.Fill(ds);
Session["dsPersonDetails"] = ds;
}
Response.Redirect("WebForm2.aspx");
}
}
}
WebForm1.aspx
<%@ 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">
<title></title>
<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";
</style>
<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>
</head>
<body>
<form id="form1" runat="server">
<div>
<div data-role="page" id="CheckboxListPage">
<div id="header" data-theme="b" data-role="header">
<h3>
List of Persons
</h3>
</div>
<div data-role="content" data-theme="a" data-mini="true">
<div>
<asp:CheckBoxList ID="PersonList"
runat="server"
AutoPostBack="True"
onselectedIndexChanged="PersonList_SelectedIndexChanged" DataSourceID="SqlDataSource1">
</asp:CheckBoxList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:myConStr %>"
SelectCommand="SELECT [name] FROM [Person_Details]">
</asp:SqlDataSource>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
</div>
</div>
</div>
</div>
</form>
</body>
</html>

New Topic/Question
Reply




MultiQuote




|