Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Nested GridView [No JavaScripts]

, 19 Jul 2009
Nesting GridViews without writing any JavaScript code [AJAX driven].
nested_gv.zip
ICONS
finance.png
HGHGH.jpg
home.png
inv.png
Main.jpg
p_orders.png
reports.png
sales.png
stock.png
supp.png
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Data.Sql;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class order_view : System.Web.UI.Page
{
    SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["IVN_sysConnectionString"].ConnectionString);
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        LinkButton l_btn = (LinkButton)sender;
        GridViewRow gvr = (GridViewRow)l_btn.NamingContainer;
        Panel p1 = (Panel)gvr.FindControl("Panel1");
        LinkButton lb1 = (LinkButton)gvr.FindControl("LinkButton1");
        if (p1.Visible == false)
        {
            p1.Visible = true;
            lb1.Text = "-";
        }
        else if (p1.Visible == true)
        {
            p1.Visible = false;
            lb1.Text = "+";
        }
        GridView gv2 = (GridView)l_btn.FindControl("GridView2");
        gv2.DataBind();
    }

    protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            SqlDataSource s = (SqlDataSource)e.Row.FindControl("SqlDataSource2");
            s.SelectParameters[0].DefaultValue = e.Row.Cells[1].Text;
        }
        DataSet dss = new DataSet();
        SqlDataAdapter daa = new SqlDataAdapter("SELECT order_status_overall FROM orders WHERE order_no='" + e.Row.Cells[1].Text + "';", conn);
        daa.Fill(dss);
        string x = "Not Received";
        int y=0;
        //foreach(DataRow drr in dss.Tables[0].Rows)
            foreach(DataRow drr in dss.Tables[0].Rows)
             {
            y=string.Compare(drr[0].ToString(),x.ToString());
            if(y==0)
            {
                e.Row.BackColor = System.Drawing.Color.LightPink;
            }
        }
    }
    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}

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

fawadhq
Software Developer
Saudi Arabia Saudi Arabia
No Biography provided

| Advertise | Privacy | Mobile
Web03 | 2.8.140926.1 | Last Updated 19 Jul 2009
Article Copyright 2009 by fawadhq
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid