<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Report.aspx.cs" Inherits="Report" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods = "true">
</asp:ScriptManager>
<div>
<center>Report</center>
<fieldset style="width: 25%; float: left;">
<legend>Type Parent</legend>
<asp:TextBox ID="txttext" runat="server" Placeholder="Type Name..." Style="width: 100%;
height: 30px;"></asp:TextBox><br />
<asp:AutoCompleteExtender ServiceMethod="GetCompletionList" MinimumPrefixLength="1"
CompletionInterval="10" EnableCaching="false" CompletionSetCount="1" TargetControlID="txttext"
ID="AutoCompleteExtender1" runat="server" FirstRowSelected="false">
</asp:AutoCompleteExtender>
<asp:Button ID="btn_save" runat="server" Text="Save" OnClick="btn_save_Click" />
</fieldset>
<div style="clear:both"></div>
<asp:GridView ID="GridView1" runat="server" />
</div>
</form>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using MyGreatVision;
public partial class Report : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString.ToString());
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GetData();
}
}
protected void btn_save_Click(object sender, EventArgs e)
{
String query = "Select * from TopBill where Pname='"+txttext.Text+"'";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dtMasterBill = new DataTable();
sda.Fill(dtMasterBill);
if (dtMasterBill.Rows.Count > 0)
{
GridView1.DataSource = dtMasterBill;
GridView1.DataBind();
string RowValue = GridView1.Rows[0].Cells[1].Text;
// do something with RowValue
con.Close();
//Response.Write("'" + RowValue + "'");
GridView gdv = new GridView();
String query1 = "Select * from TopBill where Pname='" + RowValue + "'";
SqlCommand cmd1 = new SqlCommand(query1, con);
SqlDataAdapter sda1 = new SqlDataAdapter(cmd1);
DataTable dtMasterBill1 = new DataTable();
sda.Fill(dtMasterBill1);
if (dtMasterBill.Rows.Count > 0)
{
gdv.DataSource = dtMasterBill1;
gdv.DataBind();
Response.Write(dtMasterBill1);
}
}
else
{
// fieldReptr.Visible = false;
}
}
private void GetData()
{
String query = "Select * from TopBill where Pid=0";
SqlCommand cmd = new SqlCommand(query, con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataTable dtMasterBill = new DataTable();
sda.Fill(dtMasterBill);
if (dtMasterBill.Rows.Count > 0)
{
GridView1.DataSource = dtMasterBill;
GridView1.DataBind();
}
else
{
// fieldReptr.Visible = false;
}
}
//
// Auto extender.....
//--------- Auto Extender
[System.Web.Script.Services.ScriptMethod()]
[System.Web.Services.WebMethod]
public static List<string> GetCompletionList(string prefixText, int count)
{
using (SqlConnection con = new SqlConnection())
{
con.ConnectionString = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
using (SqlCommand com = new SqlCommand())
{
com.CommandText = "select CName from TopBill where " + "cName like @Search + '%'";
com.Parameters.AddWithValue("@Search", prefixText);
com.Connection = con;
con.Open();
List<string> countryNames = new List<string>();
using (SqlDataReader sdr = com.ExecuteReader())
{
while (sdr.Read())
{
countryNames.Add(sdr["cName"].ToString());
}
}
con.Close();
return countryNames;
}
}
}
}
i want to show my data in the below hierarchy.