Ahmed
Ahmed

Reputation: 114

how to load a specific data depending on query string(in ASP .NET)?

Here is the scenario:

I have 1 master page and web-forms in that master page, All these forms are considered as Modules. Now each module will have sub menus in it.

e.g main.master

abc.aspx, xyz.aspx, uvw.aspx

sub menu of abc.aspx will be like this abc.aspx?p=video, abc.aspx?p=hom etc...

I want to load the data of ?p=home in a content div of abc.aspx or others

How to do this...

What i have done is created a function which check Request["p"]'s value, now do i have to add custom control? if yes then how to?


if you can't understand what i say, i want to load data in a specific div depending on query string.

Upvotes: 1

Views: 791

Answers (2)

Mubarek
Mubarek

Reputation: 2689

No rather check for

Request.QueryString["p"]

Update: You can Use GridView and bind it to an SqlDataSource. Set SelectCommand property of the SqlDataSource control at runtime with different statements. Something like this:

if (!IsPostBack)
{
  if(Request.QueryString["p"] =="contacts")
    SqlDataSource.SelectCommand="Select * from contacts";
   else if(Request.QueryString["p"]=="Activities")
    SqlDataSource.SelectCommand="Select * from Activities";
   ....
 }

Assuming you've passed p=xx from all pages

Upvotes: 0

Ravi Gadag
Ravi Gadag

Reputation: 15861

you can set your div tag to like this first

<div id="someid" runat="server">
 some content
</div> 


if(Reqest["p"]!=null && Request["p"].ToString()=="yourValue")
{
  someid.Visible=True;   
}

Upvotes: 1

Related Questions