473,657 Members | 2,418 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to make asp:BoundColumn a URL

Using ASP.Net v1.1 with C#.

I have an asp:DataGrid where one column is specified as follows:

<asp:BoundColum n HeaderText="Ser ial" DataField="owne r_serial_num"></asp:BoundColumn >

I might get a serial number of X01 or X02 for example. What I want to do is make that
serial number be a link to a different page like, say,

http://currentURLpath/DetailViewer.as px&serial="X02 "

So the idea is that the X02 row would have a URL for the serial number column which
also embedded in that URL an argument to which detail record to display if the user
clicks on it.

What confuses me is that the asp:BoundColumn is already showing the X02 text that I'd
want to surround with the a href HTML link tag. So do I put the link inside the
asp:BoundColumn or do I tell the BoundColumn tag something that lets me put the link
inside of it?

Any hints on how to do this? I'm an ASP.Net novice and confused.
Nov 19 '05 #1
4 2674
Hi, Randall! :)

Here's a ton of information for you:
http://msdn.microsoft.com/library/en...asp?frame=true

Short hint:
Use a TemplateColumn with a DataBound HyperLink inside.
Instead of
<asp:BoundColum n HeaderText="Ser ial"
DataField="owne r_serial_num"></asp:BoundColumn >
use
<asp:TemplateCo lumn HeaderText="Ser ial">
<ItemTemplate >
<asp:HyperLin k id="hyperlink1 "
NavigateUrl='<% #
"http://currentURLpath/DetailViewer.as px&serial=" +
DataBinder.Eval (Container, "DataItem.owner _serial_num") %>'
Text='<%# DataBinder.Eval (Container,
"DataItem.owner _serial_num") %>'
runat="server"/>
</ItemTemplate>
</asp:TemplateCol umn>
HTH,
Lars-Erik

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:er******** ******@TK2MSFTN GP12.phx.gbl...
Using ASP.Net v1.1 with C#.

I have an asp:DataGrid where one column is specified as follows:

<asp:BoundColum n HeaderText="Ser ial"
DataField="owne r_serial_num"></asp:BoundColumn >

I might get a serial number of X01 or X02 for example. What I want to do
is make that serial number be a link to a different page like, say,

http://currentURLpath/DetailViewer.as px&serial="X02 "

So the idea is that the X02 row would have a URL for the serial number
column which also embedded in that URL an argument to which detail record
to display if the user clicks on it.

What confuses me is that the asp:BoundColumn is already showing the X02
text that I'd want to surround with the a href HTML link tag. So do I put
the link inside the asp:BoundColumn or do I tell the BoundColumn tag
something that lets me put the link inside of it?

Any hints on how to do this? I'm an ASP.Net novice and confused.

Nov 19 '05 #2
dear parker;
yes you have to add some string on the tag to pull the needed str.ng from
the db and give the link that you give the url that you want.
here is an example that i use it in a repeater which pulls the url of a
photo over it it my give you a hint how to do it since it is the same code
that maybe used over the data grid bond column
<asp:HyperLin k ID="newslink" Runat="server"
NavigateUrl='<% #"news/shownews.aspx?n ewsID="+DataBin der.Eval(Contai ner,
"DataItem.ID")+ "&catid="+DataB inder.Eval(Cont ainer,
"DataItem.Catag oryMainID") %>' Font-Underline="fals e" Font-Overline="false ">
this is the section that is most neded for you
<%#"news/shownews.aspx?n ewsID="+DataBin der.Eval(Contai ner,
"DataItem.ID")+ "&catid="+DataB inder.Eval(Cont ainer,
"DataItem.Catag oryMainID") %>
here you see the databinder.eval section you can use it in your code like
this;

http://currentURLpath/DetailViewer.as px&serial="+Dat aBinder.Eval(Co ntainer,
"DataItem.Catag oryMainID")
and here you must enter the values of CatagoryMainID in your db as you like
and bind it so it will show you deffrent url over each row of that column.
Not : you can change "CatagoryMainID " name as you like and accourding to
name that you but in your db
i hope this hint may help you
-------
PLEASE DO NOT FORGET TO RATE THE ANSWER
happy coding
Muhanad YOUNIS
MCSD.NET
"Randall Parker" wrote:
Using ASP.Net v1.1 with C#.

I have an asp:DataGrid where one column is specified as follows:

<asp:BoundColum n HeaderText="Ser ial" DataField="owne r_serial_num"></asp:BoundColumn >

I might get a serial number of X01 or X02 for example. What I want to do is make that
serial number be a link to a different page like, say,

http://currentURLpath/DetailViewer.as px&serial="X02 "

So the idea is that the X02 row would have a URL for the serial number column which
also embedded in that URL an argument to which detail record to display if the user
clicks on it.

What confuses me is that the asp:BoundColumn is already showing the X02 text that I'd
want to surround with the a href HTML link tag. So do I put the link inside the
asp:BoundColumn or do I tell the BoundColumn tag something that lets me put the link
inside of it?

Any hints on how to do this? I'm an ASP.Net novice and confused.

Nov 19 '05 #3
<asp:HyperLinkC olumn
DataNavigateUrl Field="nameOfUR LToShow_CouldRe use_DataNavigat eUrlFormatStrin g"
DataNavigateUrl FormatString="h ttp://currentURLpath/DetailViewer.as px?serial={0}"
DataTextField=" owner_serial_nu m"></asp:HyperLinkCo lumn>

Nov 19 '05 #4
You can just use a HyperLink column.

URL field:
owner_serial_nu m

URL format string:
DetailViewer.as px&serial={0}

--
Remy Blaettler
Helping you collaborate better!
www.collaboral.com
"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:er******** ******@TK2MSFTN GP12.phx.gbl...
Using ASP.Net v1.1 with C#.

I have an asp:DataGrid where one column is specified as follows:

<asp:BoundColum n HeaderText="Ser ial"
DataField="owne r_serial_num"></asp:BoundColumn >

I might get a serial number of X01 or X02 for example. What I want to do
is make that serial number be a link to a different page like, say,

http://currentURLpath/DetailViewer.as px&serial="X02 "

So the idea is that the X02 row would have a URL for the serial number
column which also embedded in that URL an argument to which detail record
to display if the user clicks on it.

What confuses me is that the asp:BoundColumn is already showing the X02
text that I'd want to surround with the a href HTML link tag. So do I put
the link inside the asp:BoundColumn or do I tell the BoundColumn tag
something that lets me put the link inside of it?

Any hints on how to do this? I'm an ASP.Net novice and confused.

Nov 19 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
2684
by: Steve Hoyer | last post by:
I am trying to deploy my first asp.net app to our webserver (2K server, IIS 5) My start page comes up and you can get to the subsequent pages that are tied into our sql server (2K). Each page has a datagrid that loads up just fine, but when I click on any link that updates the page, i.e. a column header to sort the database, it returns a 404 error. Any ideas why it works the for the inital load and not on a postback?
2
3174
by: Daniel Walzenbach | last post by:
Hi, I created an ASP.NET Datagrid where a single row can be selected by clicking anywhere on the row (according to http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv_vstechart/html/vbtchTopQuestionsAboutASPNETDataGridServerControl.asp, Selecting Rows by Clicking Anywhere). Private Sub DataGrid1_ItemDataBound(ByVal sender As Object, _ ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) _
3
2156
by: Richard | last post by:
After printing a userlist to a Datagrid i want some names not to be shown. I want to know how i can make a entire datagrid row invisible. I suspect its something with the OnItemDatabound but i am kinda stuck there. but this is basicly what i want. if Username = "Deleted_User" then 'make entire table row invisible. End if
1
1531
by: rj | last post by:
Can I get the vaue of a boundcolumn at runtime using javascript? I use var lQty = document.getElementsByName("edtQty"); for(i=0;i<textBox.length;i++) { if (textBox .value > 0) .... to get the value from an asp:templatecolumn\itemtemplatecolumn and it works as expected, but if I try to access a boundcolumn this way I get a page error.
1
1104
by: roni | last post by:
in datagrid control , how can i change the width of textbox in edit mode (on <asp:BoundColumn> ) ?
1
1884
by: niki | last post by:
Hello. I have a problem with custom columns inside the datagrid. I've set up a datagrid that populates from a database; I can edit the datagrid values and update the db, so that's ok. (btw, it's not as easy as the book claims...) Now I'd like to format some columns, say date values, and what's more, I'd like to make some columns not visible and some read-only. I thought BoundColumn could be the solution, but as I create columns this...
4
2124
by: Jeff User | last post by:
Hi I tryed to solve this problem over in the framework.asp group, but still am having trouble. Hope someone here can help. using .net 1.1, VS 2003 and C# I have an asp.DataGrid control with a Delete button on the end of each row. I am unable to gain access to the event when the button is clicked. I don't fully understand how the click gets connected to the C# code,
0
3831
by: shamirza | last post by:
· What is view state and use of it? The current property settings of an ASP.NET page and those of any ASP.NET server controls contained within the page. ASP.NET can detect when a form is requested for the first time versus when the form is posted (sent to the server), which allows you to program accordingly. · What are user controls and custom controls? Custom controls: A control authored by a user or a third-party software vendor that...
1
3314
by: rn5a | last post by:
A DataGrid has a BoundColumn which changes to a TextBox when the DataGrid is in the editable mode. The rest of the columns in the DataGrid are TemplateColumns. There's an EditCommandColumn as well. All the columns including the BoundColumn but excluding the EditCommandColumn can be sorted. The column sorted is also accompanied by an image to indicate whether a column has been sorted ascendingly or descendingly. The image gets rendered when...
0
8402
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8829
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8508
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8608
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6172
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5633
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4323
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2733
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1627
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.