Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » ASP.NET » General » Downloads
 
Add your own
alternative version

Gridview inside Gridview in ASP.NET C#

, 9 Jun 2011
Gridview inside Gridview in ASP.NET C# or Nested Gridview and Update, Delete from Gridview
NestedGridView.zip
nestedgridview
App_Code
data
App_Data
Bin
AjaxControlToolkit.dll
AjaxControlToolkit.dll.refresh
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Class1
/// </summary>
public class Class1
{
	public Class1()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    public static DataSet fillDataset(string sql)
    {
        SqlConnection Scon = new SqlConnection(ConfigurationManager.ConnectionStrings["CS"].ToString());
        SqlCommand Scmd = new SqlCommand(sql, Scon);
        Scmd.CommandType = CommandType.Text;
        SqlDataAdapter adp = new SqlDataAdapter(Scmd);
        DataSet ds = new DataSet();
        try
        {
            if (Scon.State == ConnectionState.Closed)
            {
                Scon.Open();
                adp.Fill(ds);

            }
        }
        catch
        {
        }
        finally
        {
            adp.Dispose();
            if (Scon.State == ConnectionState.Open)
            {
                Scon.Close();
            }
        }
        
        return ds;
    }
    public static int nonquery(string sql)
    {
        SqlConnection Scon = new SqlConnection(ConfigurationManager.ConnectionStrings["CS"].ToString());
        SqlCommand Scmd = new SqlCommand(sql, Scon);
        Scmd.CommandType = CommandType.Text;

        int rowsaffected = 0;
        try
        {
            if (Scon.State == ConnectionState.Closed)
            {
                Scon.Open();

                rowsaffected = Scmd.ExecuteNonQuery();
            }
        }
        catch
        {
        }
        finally
        {
        }
        return rowsaffected;
    }

    public static int nonquery1(string Id, string name)
    {
        SqlConnection Scon = new SqlConnection(ConfigurationManager.ConnectionStrings["CS"].ToString());
        SqlCommand Scmd = new SqlCommand("spUpdate", Scon);
        Scmd.CommandType = CommandType.StoredProcedure;
        Scmd.Parameters.Add("@FName", SqlDbType.VarChar).Value = name;
        Scmd.Parameters.Add("@ID", SqlDbType.BigInt).Value = long.Parse(Id);
        int rowsaffected = 0;
        try
        {
            if (Scon.State == ConnectionState.Closed)
            {
                Scon.Open();

                rowsaffected = Scmd.ExecuteNonQuery();
            }
        }
        catch
        {
        }
        finally
        {
        }
        return rowsaffected;
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Prasanta_Prince
Software Developer India
India India
http://devcorners.com/
Total DotNet/Programming Solution
 
I am Prasanta Banerjee. I am an Asp.Net Developer. My site: http://devcorners.com/
Email: prasanta.it@hotmail.com
If any body wants to prepare for interview http://guru-code.blogspot.com/ is the good site.

| Advertise | Privacy | Mobile
Web03 | 2.8.140814.1 | Last Updated 9 Jun 2011
Article Copyright 2011 by Prasanta_Prince
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid