• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1905
  • Last Modified:

How to get name value pair in url in asp.net

Hi,
In an asp.net 4.0 application I want to pass parameter names and values in the url e.g. http://mysite/pages/mypage.aspx?id=34 . The application is for use within my company so SEO isn't a consideration and it would be helfpul to send people a URL as above. I have a gridview bound to a SqlDataSource and the gridview has a hyperlinkfield shown in the attached code. In mypage.aspx I have a detailsview with a SqlDataSource and a dynamic field also shown in the attached. When I click the hyperlink field in the gridview I am taken to the url but then get this invalid operation exception:
"Could not determine a MetaTable. A MetaTable could not be determined for the data source 'SqlDataSourceApplicant' and one could not be inferred from the request URL. Make sure that the table is mapped to the dats source, or that the data source is configured with a valid context type and table name, or that the request is part of a registered DynamicDataRoute."

I would be grateful for any help with this.

Thanks,

Louise


<asp:HyperLinkField DataNavigateUrlFields="id" 
            DataNavigateUrlFormatString="mypage.aspx?id={0}" HeaderText="Name" 
            SortExpression="Name" DataTextField="fullname" />

DetailsView dyanamic field:
<asp:DynamicField DataField="stage" HeaderText="Stage" />

Open in new window

0
louise001
Asked:
louise001
  • 6
  • 5
1 Solution
 
InteqamCommented:
see this link

it has many solutions

http://forums.asp.net/p/1526604/3684804.aspx
0
 
louise001Author Commented:
Hi Integam,

The link refers to an EntityDataSource and a DynamicDataManager. Are you saying that I need to add those things to the page containing the gridview?

Louise
0
 
InteqamCommented:
Well, it depends on your case, i could see 3 solutions. all for fixing the error you are getting.

0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
louise001Author Commented:
Which of the three do you suggest?
0
 
InteqamCommented:
If you are using visual web developer 2010, if the columns change in your database or you add columns to a gridview based on a column that web developer is not aware of, it may add the gridview column as a dynamic data column.  You may recieve this error.  Configure your gridviews and make sure to 'refresh the schema' before removing and re-adding any columns that were in the gridview as dynamic data columns (they have a different icon)

My suggestion would go to update the link using code behind, on item rendering event of something, not depending on binding.
0
 
louise001Author Commented:
Hi,

I'm using Visual Studio 2010. I understand that schema should be refreshed when columns are added or removed from the database output, and not having refreshed the schema isn't the cause of my problem.

Given that I know that the link is constituted correctly, irrespective of whether the link is composed using code behind or binding what I need to know is how to get the data to display on the page at the link address ie  http://mysite/pages/mypage.aspx?id=34

Thanks,

Louise
0
 
InteqamCommented:
ah, you mean when going to that page?
0
 
louise001Author Commented:
Hi,

Yes, when that page opens I want to display data depending on the id in the URL.
Thanks,
Louise
0
 
InteqamCommented:
easy

just use querystring

dim trID as string =Page.Request.QueryString("id")
0
 
louise001Author Commented:
Hi again,

Apologies that I've taken so long to reply, and thanks for your help. I didn't realise it was that straightforward :-)

Louise
0
 
InteqamCommented:
Glad you're problem has been solved.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now