ASP.NET - how to display in gridview reports - Asked By Jahir on 14-Feb-12 02:15 AM

i have from date, services, userid, username, credit debit(radiobtnlist) amount

now i want to display reports from tables each are diff tables how ?
i want qry ?

{
adap = new SqlDataAdapter("select a.fromdate,b.servicename,c.userid,c.username,d.type,e.debit,a.total from creditadd a,serve b,memreg c, serviceamount d,creditdeduct e where a.fromdate between 07-02-2012 and 14-02-2012", con);

ds = new DataSet();

adap.Fill(ds);

GridView1.DataSource = ds;

GridView1.DataBind();
}

how to take reports from other tables ?

Somesh Yadav replied to Jahir on 14-Feb-12 02:24 AM
Hi,
Here is the solution.

public DataTable compareDataTables(DataTable First, DataTable Second) { First.TableName = "FirstTable"; Second.TableName = "SecondTable";

        //Create Empty Table
       
DataTable table = new DataTable("Difference");
       
DataTable table1 = new DataTable();
       
try
       
{
           
//Must use a Dataset to make use of a DataRelation object
            using
(DataSet ds4 = new DataSet())
           
{
               
//Add tables
                ds4
.Tables.AddRange(new DataTable[] { First.Copy(), Second.Copy() });

               
//Get Columns for DataRelation
               
DataColumn[] firstcolumns = new DataColumn[ds4.Tables[0].Columns.Count];

               
for (int i = 0; i < firstcolumns.Length; i++)
               
{
                    firstcolumns
[i] = ds4.Tables[0].Columns[i];
               
}

               
DataColumn[] secondcolumns = new DataColumn[ds4.Tables[1].Columns.Count];

               
for (int i = 0; i < secondcolumns.Length; i++)
               
{
                    secondcolumns
[i] = ds4.Tables[1].Columns[i];
               
}

               
//Create DataRelation
               
DataRelation r = new DataRelation(string.Empty, firstcolumns, secondcolumns, false);

                ds4
.Relations.Add(r);

               
//Create columns for return table
               
for (int i = 0; i < First.Columns.Count; i++)

Hope it helps.
Web Star replied to Jahir on 14-Feb-12 02:30 AM
If you want to display data as report format in girdview where as data filter from different table than you just use JOIN query when you fetch data from database to fill DataSet only other thing are same.
Sandeep Mittal replied to Jahir on 14-Feb-12 02:31 AM
I think you want to show something like header/ details relationship data in gridview

Refer this post -> http://itdeveloperzone.blogspot.in/2010/11/gridview-inside-gridview-in-aspnet.html
kalpana aparnathi replied to Jahir on 14-Feb-12 03:30 AM
hi,

http://msdn.microsoft.com/en-us/library/system.data.datatable.merge%28VS.80%29.aspx

Regards,