How fill the URL field in DataGrid 4 abc.aspx?key=xyz 4 each recor

G

Guest

I have created a datagrid with ID dgEncounter in form design, and add a
HyperLink Column, Link, which is bounded to a field URLs that providing the
URL of the page to go for each record. That is not enough, since I need to
add a KEY with ?= notation to follow the URL, for example, abc.aspx?key=xyz
where abc.aspx is a item value of URLs and xyz is a value of another column.

I Do not know how to do it. In the URL field in the property of
dgEncounter, URLs is filled in. So when I click a Link, it goes to the page
abc.apsx without key key=xyz.

The following is from the HTML source of Web browser for my code, Hope it is
useful. By the way, what does it mean by 'dgEncounter$_ctl3$_ctl0',
especially, $_ctl3$_ctl0:
<td><a href="javascript:__doPostBack('dgEncounter$_ctl3$_ctl0','')"
style="color:Black;">Select</a></td><td><a href="PatientCheckOut.aspx"
target="_blank">Link</a></td><td>1</td><td>08 Jul 2005
11:32:35</td><td>Surgery
TBD</td><td>CheckOut</td><td>Administration</td><td>clinic</td><td>PatientCheckOut.aspx</td><td>3</td>

Thanks

David
 
G

Guest

Hello David,

You probably want to look at the ItemDataBound event for the datagrid. Do
something along the following in that event:

if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem)
{
// look for the hyperlink control and add key
HyperLink hl = (System.Web.UI.WebControls.HyperLink)
e.Item.FindControl("hlabc");
hl.NavigateUrl = "abc.aspx?key=" + myKey.ToString();
}


A deeper explanation and sample can be found at
http://www.codeproject.com/aspnet/ItemCreated.asp. Or do a search in google:
http://www.google.com/search?hl=en&q=itemdatabound for more.
 
G

Guest

Try:

<asp:HyperLinkColumn
HeaderText="Link"
DataNavigateUrlField="xyz_column_name"
DataNavigateUrlFormatString="abc.aspx?key={0}"
DataTextField="Showing_column_name"
/>

HTH

Elton Wang
 
G

Guest

Thanks for both of you. However,
abc.aspx should be one of field values. That is asp file name such as
abc.aspx will be different for different record.

David
 

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,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top