TreeView Example In Asp.net 2.0

Write Down Following method in TreeNodePopulateEvent Of TreeView
protected void TreeView1_TreeNodePopulate(object sender, TreeNodeEventArgs e)
    {

        PopulateSubLevel(Int32.Parse(e.Node.Value), e.Node);
    
    }


Write Down Foloowing Code in Page Load.
 protected void Page_Load(object sender, EventArgs e)
    {

        if (!Page.IsPostBack)
        {
            PopulateRootLevel();
          
        }
    }

For Populate Root Node
protected void PopulateRootLevel()
{
    con.Open();
    SqlCommand command = new SqlCommand(Query For Populate Root Node, con);
    SqlDataAdapter adapter = new SqlDataAdapter(command);
    DataSet RootTable = new DataSet();
    adapter.Fill(RootTable);
    PopulateNodes(RootTable.Tables[0], TreeView1.Nodes);
    con.Close();

}

Ser Text And Value For Each Parent Node.

    protected void PopulateNodes(DataTable dt, TreeNodeCollection nodes)
    {
        
        foreach(DataRow row in dt.Rows)
        {
            TreeNode tn=new TreeNode();
            tn.Text = "Text For Node"
            tn.Value = Value For Node ex. row["vacany_code"].ToString();
            nodes.Add(tn);
            tn.PopulateOnDemand = true;
          
        }
        
    }

Populate Child Node and Set Text And Value Field For Chid Nodes.

    protected void PopulateSubLevel(Int64 parent_id, TreeNode parent_node)
    {
        if (parent_id != 0)
        {
            con.Open();
            SqlCommand command = new SqlCommand(Query For Child, con);
            command.Parameters.Add("@employer_id", SqlDbType.Int).Value =
            parent_id;
            SqlDataAdapter adapter = new SqlDataAdapter(command);
            DataSet ChildDataSet = new DataSet();
            adapter.Fill(ChildTable);
            TreeNodeCollection nodes = parent_node.ChildNodes;
            foreach (DataRow row in titlesForAuthors.Tables[0].Rows)
            {
                TreeNode tn = new TreeNode();
               
                tn.Text = "Text For Child Node
                tn.Value = "Value For Chid Node";
                nodes.Add(tn);
                tn.PopulateOnDemand = false;
            }
            con.Close();
          }
    }


Enjoy !!!!!!!!!!!!!!!!!!




Prev Post                                                      All Post                                                           Next Post



Posted in | 2 comments

Tab Control In ASP.Net Without third Party Controls




-> Tab Menu in ASP.Net can Be Archived by DIV. In this We Need two Div (First Consider Tab with 2 Menu)Put this Two DIV in Table and First Row of Table Divide in two column, Name This two Column As You Wish For Example In Below Screen Short There Are Two column Name Given Candidate(s) Suitable For You and Candidate(s) Forward by you.On Clicking of Individual Column Name We need to Hide or Show Div




 Now Write Down Below Code in First Cell click that means on Candidate(s) Suitable For You
 Click.

< td  id="celltech" class="MenuTabSelected" onclick="ShowTabContent('tech');HideTabContent('post');" style="width: 300px; height: 22px" >
               Candidate(s) Suitable For You < /td >



On Second Cell Click
< td  id="cellpost" class="MenuTab" onclick="HideTabContent('tech');ShowTabContent('post');" style="width: 300px; height: 22px" >
                            Candidate(s) Forward by you < /td >


And Write Down Following Java Script






< script type="text/javascript" language="javascript" >
        function ShowTabContent(TabID)
        {
        
            var TabControl=document.getElementById('cell' + TabID);
            var Tabdiv =document.getElementById('dv' + TabID);
            Tabdiv.style.display='block';
            TabControl.className='MenuTabSelected';
            return false;
        }
        function HideTabContent(TabID)
        {
        
            var TabControl=document.getElementById('cell' + TabID);
            var Tabdiv =document.getElementById('dv' + TabID);
            Tabdiv.style.display='none';
            TabControl.className='MenuTab';
            return false;
        }
      < /script >

Write Down Following code on Before Table Start. < script type="text/javascript" > ShowTabContent('tech');HideTabContent('post'); < /script > So Now your Tab control Ready Just See Below screenshot. CSS FOR Active\Deactive
.MenuTab
{

   color:black; 
   background-color  :#dce7f1;
   height :25px;
 font-size: 8pt;
 font-family: verdana;
 font-weight: bold;
 border: None;
 color:black;
    text-transform:uppercase;
 cursor:pointer;

    
}
.MenuTabSelected
{

  color :White; 
  background-image :url("./images/mainbg.jpg");
  height :28px;
    text-align:center; 
    vertical-align:middle;
 cursor:pointer;
 
 font-family:Verdana;
 font-size:12px;
 font-weight:bold;
   
   
}
 
 
 
Just take Image From your collection

Enjoy !!!!!!!!!!!!!



Prev Post                                                      All Post                                                           Next Post



Posted in | 0 comments

Open Child Window From Parent Window using Java script and closing

in parent Window


   Response.Write(" < script > window.open('Vacancy_Detal.aspx?lbl_vac_code=" + vac_code.Text + "','','left=150px,top=70px,width=812,height=650,scrollbars=yes,toolbar=0,resizable=0,location=no,status=no'); < /script > ");
  

In Child Window

    Response.Write(" < script > window.opener.location.href='Vacancy_Detal.aspx ';  < /script > ");
        Response.Write(" < script > self.close();  < /script > ");



Open Pop up Window From Java Script

< script  language="javascript" type="text/javascript" >
function showSMSPopUp(ctrl)
{
window.open('Job_search_Detail.aspx?vac_code=' + ctrl + '','','left=20px,top=70px,width=830,height=650,scrollbars=yes,toolbar=0,resizable=0,location=no,status=no');
return false;
}
< /script >


Closing Popup Window On Server Side.

Response.Write("< script  > this.close(); window.open('Tell_Frd_Vacancy.aspx?vac_code=" + vacancy_code + "','','left=20px,top=70px,width=828,height=650,scrollbars=yes,toolbar=0,resizable=0,location=no,status=no'); < /script >");


Prev Post                                                      All Post                                                           Next Post



Posted in | 0 comments

Maintain Checkbox state In GridView While Paging in ASP.Net


There Are Most Cases when we required checkbox In grid view and Also Paging. But there are Problem Exists if We Used Paging And Checkbox Field When We Go Next Page Then Page Post back to Server and All Checked Value clear so There are Required to Maintain all checkbox
Value.
I take one Problem which exists with me when I am developing one job site during developing this site I come on point to maintain checked value. User search jobs there are lot’s of jobs So all jobs
Display in Grid view I have checkbox in Gridview.Now when user select multiple job and save I need to maintain all paging checked Data. I have Archived this one by following method.
First Of All when we Changed Page Or Press Submit button We Need to Stored All Checked Data. And Pressing Submit button Save Data From that Storage.
On Select Page Index Changing Event I Call Two Method.
After Gridview Bind called PupulateoldCheckValue Metohd
And On Page Index Changing called StoreOldValue Method.
private void StoreOldValue()
    {
        ArrayList categoryIDList = new ArrayList();
        foreach (GridViewRow row in grd_search_result.Rows)
        {
            Label can_id = (Label)row.FindControl("lbl_vacancy_code");
            bool result = ((CheckBox)row.FindControl("chk_select")).Checked;

            // Check in the Session
            if (Session["CHECKED_ITEMS"] != null)
                categoryIDList = (ArrayList)Session["CHECKED_ITEMS"];
            if (result)
            {
                if (!categoryIDList.Contains(can_id.Text))
                    categoryIDList.Add(can_id.Text);
            }
            else
                categoryIDList.Remove(can_id.Text);
        }
        if (categoryIDList != null && categoryIDList.Count > 0)
            Session["CHECKED_ITEMS"] = categoryIDList;
    }





    private void PupulateoldCheckValue()
    {
        ArrayList categoryIDList = (ArrayList)Session["CHECKED_ITEMS"];
        if (categoryIDList != null && categoryIDList.Count > 0)
        {
            foreach (GridViewRow row in grd_search_result.Rows)
            {
                Label can_id = (Label)row.FindControl("lbl_vacancy_code");
                if (categoryIDList.Contains(can_id.Text))
                {
                    CheckBox myCheckBox = (CheckBox)row.FindControl("chk_select");
                    myCheckBox.Checked = true;
                }
            }
        }
    }




Prev Post                                                      All Post                                                           Next Post



Posted in | 3 comments