Asp.net cross-page transmission of control binding parameters
Source: Internet
Author: User
Two days ago, I used vs2005 to write a website because of my work. After many pages are completed, I found that using the Database Control girldview to bind the sqldatasource control can improve the writing efficiency and save a lot of trouble. However, since vs2005 was just started, it is not very suitable. After all the data is basically sorted out, it is found that some data that has already been successfully bound is not capable of cross-page link transmission parameters! I wanted to add a linkbutton control in the form of a custom template, and then included a parameter hyperlink such as newspage. aspx IN THE postbackurl attribute? Newsid = <% # eval ("ID") %> The result shows that this does not reach the purpose of passing parameters, after learning, we found that the original value of this attribute must comply with the URL specification. That is to say, some special characters such as "% ^ & *" are replaced by %, and % is exactly the unique difference between page encoding and tags, the consequence is that Code It cannot transmit accurate data. In fact, the solution is very simple, that is, to delete the original bound columns directly in girldview and click the small arrow above to select "Add new column" in the pop-up dialog box ", in the pop-up dialog box, select the "hyperlinkfield" option from the "select field type" drop-down menu. Then, you will find that the menu content is changed! You can customize text in "hyperlink text", but I use "retrieve text from data fields" to display the bound data fields as text, then there is the most important parameter. In the "hyperlink URL", you must manually enter the URL and add parameters, such as connecting to newspage. on the ASPX page, you must first select the data to be used as the parameter in "Get URL from data field" and then write it as "newspage" in "url Format String. aspx? Newsid = {0! How can we accept parameters! In newspage. drag a sqldatasource control into the ASPX page and configure the data. For example, you need to search for other fields in the table based on the ID in this example, click the where button in the select configuration dialog box, in the pop-up dialog box, select the "ID" field in the "column" selection box, and then select the querystring option in the "Source" selection box under the "=" operator by default, then fill in the corresponding parameter name on the right. Here is "newsid" and click the "Add" button below to add a SELECT statement with parameters, click "OK" and then bind data with the control to implement cross-page parameter transfer of hyperlinks! No code line was written throughout the process!
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service