Bulleted
List
BulletedList.aspx
<body>
<form id="form1" runat="server">
<asp:BulletedList ID="blstSubjects" runat="server" ForeColor="#FF3300">
<asp:ListItem>Maths</asp:ListItem>
<asp:ListItem>Physics</asp:ListItem>
<asp:ListItem>Chemistry</asp:ListItem>
</asp:BulletedList>
<asp:BulletedList ID="blstBatches" runat="server">
</asp:BulletedList>
<asp:BulletedList ID="blstCustomers" runat="server">
</asp:BulletedList>
</form>
</body>
Code Behind File – BulletedList.aspx.cs
public partial class BulletedList : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
ShowBatches();
ShowEmployeeNames();
}
}
protected void ShowBatches()
{
blstBatches.Items.Add(".NET");
blstBatches.Items.Add("Infra");
blstBatches.Items.Add("Oracle");
blstBatches.Items.Add("Java");
}
protected void ShowEmployeeNames()
{
SqlConnection con;
con = new SqlConnection(ConfigurationManager
.ConnectionStrings["MyDBConStr"].ConnectionString);
con.Open();
SqlCommand cmd;
cmd = new SqlCommand ("Select distinct EmpName
from tabEmployee order by EmpName", con);
SqlDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
blstCustomers.Items.Add(dr["EmpName"].ToString());
}
dr.Close();
cmd.Dispose();
con.Close();
}
}//class end
No comments:
Post a Comment