Grouping controls on different child pages in asp.net
<p>what i have done is login and the username appears in my masterpage in a label. what i need to do is if the logged in user has admin permission make visible controls on several child pages (including a gridview deletecontrol that is there on one child page). have be struggling to figure it out. just want to learn. </p>

<p>Is there a way to class all the controls under a class call admin and call from masterpage on checking user permission?</p>

<p>Loginpage code behind</p>

<pre><code>using System;
using System.Collections;
using System.Configuration;
using System.Data;
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.Adapters;

public partial class login1 : System.Web.UI.Page
{

    public void Page_Load(object sender, EventArgs e)
    {

    }

    protected void LoginButton_Click(object sender, EventArgs e)
    {        
        DataSet ds = new DataSet();
        ds = WCGSQL.showdata("select * from Login where Username='" + UserName.Text + "' and Password='" + Password.Text + "'");
        if (ds.Tables[0].Rows.Count != 0)
        {

            Session["Username"] = UserName.Text;
            Response.Redirect("Home.aspx");

        }
        else
        {
            FailureText.Visible = true;
            FailureText.Text = "Invalid Login";
        }
    }
}
</code></pre>

<p>App/code code behind</p>

<pre><code>using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;

public class WCGSQL
{
    static SqlConnection con = new SqlConnection(@"Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|WCG.mdf;Integrated Security=True;User Instance=True");
    static public Boolean savedata(string qurt)
    {
        try
        {
            SqlCommand cmd = new SqlCommand(qurt, con);
            con.Open();
            cmd.ExecuteNonQuery();
            return true;
        }
        catch
        {
            return false;
        }
        finally
        {
            con.Close();
        }


    }

    static public DataSet showdata(string qurt)
    {
        DataSet ds = new DataSet();
        try
        {
            SqlDataAdapter adp = new SqlDataAdapter(qurt, con);
            adp.Fill(ds);
            return ds;
        }
        catch
        {
            return ds;
        }
    }

}
</code></pre>
