Tuesday, 25 May 2010

ASP .NET: recall page through gridview selection



using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.UI;

using System.Web.UI.WebControls;



public partial class Help_Filter : System.Web.UI.Page

{

    protected void Page_Load(object sender, EventArgs e)

    {



        if (Request.QueryString["FilterValue"] == null)

            Session.Remove("FilterValue");

        else

            Session["FilterValue"] = Request.QueryString["FilterValue"];



        if (Session["FilterValue"] != null)

        {

            string test = Session["FilterValue"].ToString();

            string strscript = "<script language=javascript> parent.parent.GB_hide(); </script>";

            //if (window.opener && !window.opener.closed) { window.opener.location.reload(); } </script>";

            //window.top.close();

            if (!ClientScript.IsStartupScriptRegistered("clientScript"))

                ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strscript);





        }

    }



    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)

    {

        GridView d = (GridView)sender;



        string valueSelected = d.SelectedRow.Cells[0].Text;

        Session["FilterValue"] = valueSelected;

        string strscript = "<script language=javascript> parent.parent.GB_hide(); </script>";

        //if (window.opener && !window.opener.closed) { window.opener.location.reload(); } </script>";

        //window.top.close();

        if (!ClientScript.IsStartupScriptRegistered("clientScript"))

            ClientScript.RegisterStartupScript(Page.GetType(), "clientScript", strscript);

    }



    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)

    {



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

        {

            e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor='#ceedfc'");

            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=''");

            e.Row.Attributes.Add("style", "cursor:pointer;");

            e.Row.Attributes.Add("onclick", "location='PreviousFilter.aspx?FilterValue=" + e.Row.Cells[0].Text + "'");

        }

    }

}


No comments:

Post a Comment