using System.Data.SqlClient;
using System.Collections;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("user id=sa;password=uday;database=mydb;data source=localhost");
SqlCommand cmd = new SqlCommand("select empno,ename from emp",con);
con.Open();
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(dt);
List<Emp> listemp = new List<Emp>();
foreach (DataRow dr in dt.Rows)
{
Emp obj = new Emp();
obj.Empno = Convert.ToInt16(dr[0]);
obj.EmpName = Convert.ToString(dr[1]);
listemp.Add(obj);
}
Context.Session["EMPDETAILS"] = listemp;
con.Close();
}
}
Default.aspx.cs Image
Default.aspx
<head runat="server">
<link rel="stylesheet" href="css/common.css" type="text/css" />
<link type="text/css" rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/themes/ui-lightness/jquery-ui.css" />
<link type="text/css" href="css/ui.multiselect.css" rel="stylesheet" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.10/jquery-ui.min.js"></script>
<script type="text/javascript" src="js/plugins/localisation/jquery.localisation-min.js"></script>
<script type="text/javascript" src="js/plugins/scrollTo/jquery.scrollTo-min.js"></script>
<script type="text/javascript" src="js/ui.multiselect.js"></script>
<script type="text/javascript">
$(function () {
$.localise('ui-multiselect', {/*language: 'en',*/ path: 'js/locale/' });
$(".multiselect").multiselect();
$('#switcher').themeswitcher();
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<%
List<Emp> obj = new List<Emp>();
%>
<% if (Context.Session["EMPDETAILS"] != null)
{
obj = (List<Emp>)Context.Session["EMPDETAILS"];
}
%>
<select size="4" id="EmpName" class="multiselect" multiple="multiple" name="EmpName[]">
<%
if (obj != null && obj.Count != 0) {
for (int i = 0; i < obj.Count; i++) {
Emp listemp = (Emp)obj[i]; %>
<option value="<%=listemp.Empno%>"> <%=listemp.EmpName%></option> <%
}
}
%>
</select>
<br/>
<asp:Button ID="Button1" runat="server" Text="Save Reports" />
</div>
</form>
</body>
==================================================
No comments:
Post a Comment
Thank you for visiting my blog