<%@ Page Title="" Language="C#" MasterPageFile="~/ms_master.master" AutoEventWireup="true" CodeFile="ourServices.aspx.cs" Inherits="ourServices" %>
//----------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
public partial class ourServices : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["vsoft09_asarkariConnectionString"].ConnectionString);
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
PopulateMenu();
}
}
DataSet GetMenuData()
{
SqlDataAdapter dadCats = new SqlDataAdapter("SELECT serviceMst.* FROM dbo.serviceMst", con);
SqlDataAdapter dadProducts = new SqlDataAdapter("SELECT serviceSubMst.* FROM dbo.serviceSubMst", con);
DataSet dst = new DataSet();
dadCats.Fill(dst, "serviceMst");
dadProducts.Fill(dst, "serviceSubMst");
dst.Relations.Add("Children", dst.Tables["serviceMst"].Columns["row_id"], dst.Tables["serviceSubMst"].Columns["ref_row_id"], false);
return dst;
}
void PopulateMenu()
{
System.Data.DataSet dst = GetMenuData();
foreach (System.Data.DataRow masterRow in dst.Tables["serviceMst"].Rows)
{
TreeNode masterItem = new TreeNode(masterRow["serviceName"].ToString());
TreeView1.Nodes.Add(masterItem);
foreach (System.Data.DataRow childRow in masterRow.GetChildRows("Children"))
{
TreeNode childItem = new TreeNode(childRow["SubService"].ToString());
masterItem.ChildNodes.Add(childItem);
}
}
}
}
OUR SERVICES
No comments:
Post a Comment