adil.hafiz652 0 Newbie Poster

hi,
i am not able to display heirarchical data in my gridview when it is coming from a single table,,,,,,it works fine when i use more than one table....plzzzz its urgent

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;




public partial class _Default : System.Web.UI.Page
{
   

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
                BindData();
        }

        AppFunctions sFunctions = new AppFunctions();
        DataSet ds;
        DataSet ds1;

        private void BindData()
        {
            DataTable dt1 = new DataTable();
            
            ds = sFunctions.setDataSet("Select ProjectID,ProjectName,ProjectStreet,ProjectCity,ClientID,EmployeeID from Project where ParentProjectID='Main' ", "Project");

            outGV.DataSource = ds.Tables["Project"];
            outGV.DataBind();
           

        }


        protected void outGV_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            //DataView dv = new DataView(ds.Tables["Project"]);



            //DataRelation parentchild = new DataRelation("parentchild", ds.Tables["Project"].Columns["ProjectID"], ds.Tables["Project"].Columns["ParentProjectID"]);
            //ds1.Relations.Add(parentchild);

            //foreach (DataRow rowist in ds.Tables["Project"].Rows)
            //{

            //    //lbllist.Text += " " + rowist["ParentProjectID"];
            //    //lbllist.Text += "<br/></b>" + rowist["ProjectID"];

            //    DataRow[] drow = rowist.GetChildRows(parentchild);


            //    foreach (DataRow row2nd in drow)
            //    {


            //        //lbllist.Text += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
            //        //Session["projectid"] = row2nd["ProjectID"] + "<br/>";


            //    }




            //}



            GridViewRow row = e.Row;
            if (row.DataItem == null)
            {
                return;
            }


            //    //Find  Child GridView control

            if (e.Row.RowType == DataControlRowType.DataRow)
            {

                GridView gv = new GridView();
                gv = (GridView)row.FindControl("inGV");




                //    //Expand the ist Child grid
                ClientScript.RegisterStartupScript(GetType(), "Expand", "<SCRIPT LANGUAGE='javascript'>expandcollapse('div" + ((DataRowView)e.Row.DataItem)["ProjectID"].ToString() + "','one');</script>");

                ////    //Prepare the query for Child GridView by passing the ID of the parent row
                ds1 = sFunctions.setDataSet("select ProjectID,ParentProjectID,ProjectPhase from Project" , "Project");

                gv.DataSource = ds1;
                gv.DataBind();
            }
        }

        protected void inGV_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            //Check if this is our Blank Row being databound, if so make the row invisible
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (((DataRowView)e.Row.DataItem)["ProjectID"].ToString() == String.Empty) e.Row.Visible = false;
            }




            //GridViewRow row = e.Row;
            //if (row.DataItem == null)
            //{
            //    return;
            //}

            ////Find Child GridView control
            //GridView gv1 = new GridView();
            //gv1 = (GridView)row.FindControl("ininGV");

            ////Expand the 2nd Child grid
            //ClientScript.RegisterStartupScript(GetType(), "Expand", "<SCRIPT LANGUAGE='javascript'>expandcollapse('divp" + ((DataRowView)e.Row.DataItem)["ID"].ToString() + "','one');</script>");

            ////Prepare the query for Child GridView by passing the ID of the parent row
            //gv1.DataSource = sFunctions.setDataTable("Select * from info where ID='" + ((DataRowView)e.Row.DataItem)["ID"].ToString() + "'", "info");
            //gv1.DataBind();

        }



        protected void ininGV_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            //GridViewRow row = e.Row;
            //if (row.DataItem == null)
            //{
            //    return;
            //}

            ////Find Child GridView control
            //GridView gv1 = new GridView();
            //gv1 = (GridView)row.FindControl("inininGV");

            ////Expand 3rd the Child grid
            //ClientScript.RegisterStartupScript(GetType(), "Expand", "<SCRIPT LANGUAGE='javascript'>expandcollapse('divx" + ((DataRowView)e.Row.DataItem)["ID"].ToString() + "','one');</script>");

            ////Prepare the query for Child GridView by passing the ID of the parent row
            //gv1.DataSource = sFunctions.setDataTable("Select * from tax where ID='" + ((DataRowView)e.Row.DataItem)["ID"].ToString() + "'", "tax");
            //gv1.DataBind();




        }


        protected void inininGV_RowDataBound(object sender, GridViewRowEventArgs e)
        {

            ////Check if this is our Blank Row being databound, if so make the row invisible
            //if (e.Row.RowType == DataControlRowType.DataRow)
            //{
            //    if (((DataRowView)e.Row.DataItem)["ID"].ToString() == String.Empty) e.Row.Visible = false;
            //}



        }



    

}