Solved

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

Posted on 2010-09-08
11
1,771 Views
Last Modified: 2012-08-14
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
Comment
Question by:louise001
  • 6
  • 5
11 Comments
 
LVL 7

Expert Comment

by:Inteqam
ID: 33624861
see this link

it has many solutions

http://forums.asp.net/p/1526604/3684804.aspx
0
 

Author Comment

by:louise001
ID: 33624962
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
 
LVL 7

Expert Comment

by:Inteqam
ID: 33625072
Well, it depends on your case, i could see 3 solutions. all for fixing the error you are getting.

0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:louise001
ID: 33625088
Which of the three do you suggest?
0
 
LVL 7

Expert Comment

by:Inteqam
ID: 33625118
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
 

Author Comment

by:louise001
ID: 33625147
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
 
LVL 7

Expert Comment

by:Inteqam
ID: 33625204
ah, you mean when going to that page?
0
 

Author Comment

by:louise001
ID: 33625281
Hi,

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

Accepted Solution

by:
Inteqam earned 500 total points
ID: 33627357
easy

just use querystring

dim trID as string =Page.Request.QueryString("id")
0
 

Author Closing Comment

by:louise001
ID: 33741466
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
 
LVL 7

Expert Comment

by:Inteqam
ID: 33741821
Glad you're problem has been solved.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question