How to display parameter passed to a page in a textbox control

M

Morris Neuman

Hi,

I have a gridview control on a page that has as its column a hyperlink
field. This hyperlink field opens another page and passes a parameter.
The hyperlink field has values as follows:
DataNavigateUrlFormatString = ManageUser-MBoxes.aspx?User={0}
DataNavigateUrlsFields = UserName.
The gridview is bound to an SqlDataSource control which returns the value of
UserName.

I want to display the value of the selected UserName field passed in the
parameterwhen the linked page is open in a TextBox control.

How do I bind the value of the TextBox control the the parameter passed to
the page via the hyperlink?

Any help would be appreciated.
 
S

Steven Cheng[MSFT]

Hi Morris,

As for the "bind url parameter from linked page to textbox" issue, I think
you can consider the following means:

1. If using code behind is acceptable, you can simply put the following
code in Page_load event to attach the querystring parameter to the Textbox.
e.g.

===============
protected void Page_Load(object sender, EventArgs e)
{
txtUsername.Text = Request.QueryString["User"];
}
===============

2. Another approach is using databinding expression, e.g.

<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtUsername" runat="server" Text='<%#
Request.QueryString["User"] %>'></asp:TextBox>

but you need to explicitly call "DataBind" method of the textbox to trigger
the databinding:

protected void Page_Load(object sender, EventArgs e)
{
............
txtUsername.DataBind();

}



3. Another means is use the new feature of ASP.NET 2.0, you can build a
custom expression builder. This can help you embed normal codesnippet in
your ASP.NET server control's tag(attribute). Here is a good blog article
detailedly describe this:

#The CodeExpressionBuilder
http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionB
uilder.aspx

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top