Hello!! I have an issue that I am stuck on. I have a form is sending a queryString to a page that I am accessing in my code file to determine whether or a not a panel (that contains a gridview) should be visible. For example the url being passed is: TestURL?Selection=Department.
I am using a switch statement in C#. The default is being returned everytime and shouldn't be. If I comment out the default then nothing is returned.
Thanks for the input!! I changed String to string - great catch!! I added a breakpoint to check the value in the queryString and it is null. I need to figure out why it is not passing it.
THANKS!! I finally saw the issue. The querystring variable on the passing page was incorrect. The variable is "Section" not "Selection". Thanks for everyones help.
THANKS!! I finally saw the issue. The querystring variable on the passing page was incorrect. The variable is "Section" not "Selection". Thanks for everyones help.
gordon1221
Member
12 Points
117 Posts
Panel Visibility Issue
Apr 16, 2012 07:48 PM|LINK
Hello!! I have an issue that I am stuck on. I have a form is sending a queryString to a page that I am accessing in my code file to determine whether or a not a panel (that contains a gridview) should be visible. For example the url being passed is: TestURL?Selection=Department. I am using a switch statement in C#. The default is being returned everytime and shouldn't be. If I comment out the default then nothing is returned.
Here is an example of the panel:
<asp:Panel ID="DepartmentPanel" cssclass="panel" runat="server" Visible="False">
Here is my code in the code file:
public partial class Department_Main : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
String ShowGrid = Request.QueryString["Selection"];
switch (ShowGrid)
{
case "Department":
DepartmentPanel.Visible =true;
break;
case "Building":
BuildingPanel.Visible =true;
break;
default:
DepartmentPanel.Visible =true;
break;
}
}
Can someone let me know what I am doing wrong or even a better way to accomplish this. Thanks in advance!!
Sparkers
Contributor
2086 Points
470 Posts
Re: Panel Visibility Issue
Apr 16, 2012 07:52 PM|LINK
try writing your case statements like this
case (string) "Department"
DepartmentPanle.Visible=true;
break;
rickjames961
Participant
775 Points
174 Posts
Re: Panel Visibility Issue
Apr 16, 2012 07:54 PM|LINK
String ShowGrid should be string ShowGrid for starters. Have you put a breakpoint there to see what is being placed into the variable ShowGrid?
Friedrich Nietzsche
Nasser Malik
Star
11644 Points
1788 Posts
Re: Panel Visibility Issue
Apr 16, 2012 08:02 PM|LINK
i checked your code.. it is working fine..
Default only returns when there is no query string or query doesn't match to any case statement..
Skype: maleknasser1
sriramabi
Contributor
4351 Points
1277 Posts
Re: Panel Visibility Issue
Apr 16, 2012 08:07 PM|LINK
hi
change this line
string ShowGrid = Request.QueryString["Selection"];
thank u
gordon1221
Member
12 Points
117 Posts
Re: Panel Visibility Issue
Apr 16, 2012 10:21 PM|LINK
Thanks for the input!! I changed String to string - great catch!! I added a breakpoint to check the value in the queryString and it is null. I need to figure out why it is not passing it.
sriramabi
Contributor
4351 Points
1277 Posts
Re: Panel Visibility Issue
Apr 16, 2012 10:23 PM|LINK
pls put send querstring code
i think u r send selection value is null...but not surly pls post u r code
thank u
gordon1221
Member
12 Points
117 Posts
Re: Panel Visibility Issue
Apr 16, 2012 10:29 PM|LINK
THANKS!! I finally saw the issue. The querystring variable on the passing page was incorrect. The variable is "Section" not "Selection". Thanks for everyones help.
sriramabi
Contributor
4351 Points
1277 Posts
Re: Panel Visibility Issue
Apr 16, 2012 10:31 PM|LINK
Yes i m alredy guss this.cheers !!!!
if(Request.QueryString["Section"].ToString()!=Null)
{
string ShowGrid = Request.QueryString["Section"];
}
markfitzme
Star
14471 Points
2236 Posts
Re: Panel Visibility Issue
Apr 16, 2012 10:57 PM|LINK
Don't check like this: if(Request.QueryString["Section"].ToString()!=Null)
THis will throw an error the second you call ToString() if there is no Section.
You need to check to see if:
if(Request.QueryString["Section"] != null)