Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 20th, 2007, 11:48 AM
Authorized User
 
Join Date: Dec 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default Visible GridView

I have 2 datagrid's on my page. What I'm trying to do is for certain conditions to show one or both grids. I getting an error "CS1518: Expected class, delegate, enum, interface, or struct"
Here is my code
 void Page_Load(Object sender , EventArgs e)
    {
    if (! IsPostBack )

        BindDataGrid();

    }

    void BindDataGrid()
    {
    String constring, strPatientID;
    SqlConnection conEck;
    strPatientID = Request.QueryString["id"];

    constring = ConfigurationSettings.AppSettings["constring"];
    conEck = new SqlConnection(constring);
    SqlCommand cmdSql = new SqlCommand("SELECT * FROM [PatientRecord] WHERE [PatientID] =" + strPatientID, conEck);
    conEck.Open();
    RightGrid.DataSource = cmdSql.ExecuteReader();
    RightGrid.DataBind();
    conEck.Close();
    conEck.Open();
    LeftGrid.DataSource = cmdSql.ExecuteReader();
    LeftGrid.DataBind();
    conEck.Close();
    ShowGrid();
    }
    void ShowGrid()
    {
        strPatientID = Request.QueryString["id"];
        String constring;
        SqlCommand cmdTreatment;
        SqlParameter parmReturn;
        SqlConnection conEzy;
        int intResult;

        constring = ConfigurationSettings.AppSettings["constring"];
        conEzy = new SqlConnection(constring);
        cmdTreatment = new SqlCommand("PatientTreatment", conEzy);
        cmdTreatment.CommandType = CommandType.StoredProcedure;
        parmReturn = cmdTreatment.Parameters.Add("RETURN_VALUE", SqlDbType.Int);
        parmReturn.Direction = ParameterDirection.ReturnValue;
        cmdTreatment.Parameters.Add("@patientid", strPatientID);
        conEzy.Open();
        cmdTreatment.ExecuteNonQuery();
        intResult = System.Convert.ToInt32(cmdTreatment.Parameters["RETURN_VALUE"].Value);
        conEzy.Close();

        Cache["Treatment"] = intResult;
        string treatment = Convert.ToString(Cache.Get("Treatment"));
        if (treatment == 1)
        {
            RightGrid.Visible="true";
            LeftGrid.Visible="false";
        }
        else if (treatment == 2)
        {
            LeftGrid.Visible="true";
            RightGrid.Visible="false";
        }
        else
        {
           RightGrid.Visible="true";
           LeftGrid.Visible="true";
        }
      }
    }

Any suggestions?

Thanks

 
Old March 20th, 2007, 11:54 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

witch line is throwing the error???

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
 
Old March 20th, 2007, 12:19 PM
Authorized User
 
Join Date: Dec 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Its in the if statement. When I take it out everything is fine.

 
Old March 20th, 2007, 01:07 PM
Authorized User
 
Join Date: Dec 2005
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Got it.
if (treatment == "1")
{
   this.RightGrid.Visible = true;
   this.LeftGrid.Visible = false;

}







Similar Threads
Thread Thread Starter Forum Replies Last Post
visible/invisible stealthdevil Access VBA 4 December 1st, 2006 05:40 PM
image not visible somsahi Struts 2 July 27th, 2006 02:25 PM
Panel.visible shai505 C# 1 April 25th, 2006 05:10 AM
visible vs. not visible on form akibaMaila VB.NET 2002/2003 Basics 2 August 15th, 2005 02:40 PM
Column not visible Chronos879 Access 1 October 2nd, 2003 08:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.