473,508 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Multiple URL Fields in a datagrid

Hi there,

I have a datagrid that is bound to a datasource. The grid has a hyperlink
column and I want to generate the URL using the URL Field and URL Format
String fields in the Property Builder.

The problem I'm running into is trying to generate the URL with more than
one URL Field entry. I need to have more than field but I can't figure out
how to add more than one field in the URL Field textbox. Is it possible?

I would want the URL Format String to look something like...

MyURL.aspx?field_1={0}&field_2={1}

Any help would be greatly appreciated.

Carlo.
Nov 18 '05 #1
1 2623
You can't do it using a normal bound column.
You need a template column.

Then in the dg_ItemDataBound event you create an instance of the hyperlink
and find it using FindControl and then set its properties.
In this case the dg is bound to a collection and the index of the collection
equals the index of the grid. So you can always identify whcih row you are
on.

================================================== =====================
<asp:TemplateColumn SortExpression="myColumn" HeaderText="My Header">
<ItemTemplate>
<asp:Hyperlink id="hylMyColumn"
runat="server"></asp:Hyperlink>&nbsp;
</ItemTemplate>
</asp:TemplateColumn>
================================================== =====================

Private Sub dg_ItemDataBound(ByVal sender As Object, ByVal e As
DataGridItemEventArgs) Handles dg.ItemDataBound
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType =
ListItemType.AlternatingItem Then

'need to take paging into account!
Dim mIndex As Integer = CType(sender, DataGrid).PageSize *
CType(sender, DataGrid).CurrentPageIndex + e.Item.ItemIndex

'set hyperlinks values:
'Note: in the HTML the &nbsp; is required because the grid cells will
change shape w/o it when there is no data.

Dim ohylMyColumn As HyperLink =
CType(e.Item.FindControl("hylMyColumn"), HyperLink)

ohylMyColumn.NavigateUrl =
"javascript:LeftSideWin('ViewSomePage.aspx?Key =" & mCollection(mIndex).key &
_
"&KeyType=" & mCollection(mIndex).keytype & "','MyScreen');"

oHylInvNumber.Text = mCollection(mIndex).MyDescription

End If
End Sub
================================================== =====================
--
Joe Fallon


"carlor" <ca****@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hi there,

I have a datagrid that is bound to a datasource. The grid has a hyperlink
column and I want to generate the URL using the URL Field and URL Format
String fields in the Property Builder.

The problem I'm running into is trying to generate the URL with more than
one URL Field entry. I need to have more than field but I can't figure out
how to add more than one field in the URL Field textbox. Is it possible?

I would want the URL Format String to look something like...

MyURL.aspx?field_1={0}&field_2={1}

Any help would be greatly appreciated.

Carlo.

Nov 18 '05 #2

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

Similar topics

3
2556
by: Julio Sarmiento | last post by:
Can anyone help me???? I have a table that I need to get the sum of four individual fields and then rank them from highest to lowest total. After summing up the four fields individually and...
1
18236
by: Brian | last post by:
I have a dataset containing 2 tables. I need to fill a datagrid using data from both of these. If I could create a SQL Statement to fill the datagrid, it would look like this: SELECT...
2
2316
by: Sky | last post by:
Hello: Another question about trying to wring functionality from a DataGrid... Have a DB table of "Contacts" -- 14 or more fields per record Show in datagrid -- but only 5 columns (First,Last,...
1
3261
by: Andrew | last post by:
Hey all, I am very new to ASP.Net (and .Net in general), but that isn't stopping the boss from wanting to begin new projects in it. This latest project has me kinda stumped and after a couple...
3
2549
by: D. Shane Fowlkes | last post by:
Sorry for the length of this post. I have created a rather complex form which has a header/line item (parent and child records) structure. It's for an intranet. A screenshot can be seen here: ...
7
2450
by: Dave | last post by:
Hi, Maybe I'm missing something with the DataKeyField attribute of a datagrid but it seems that it's somewhat limiting since this only allows you to specify one field as the key. I have a...
1
3322
by: Bob Loveshade | last post by:
I am looking for an example that shows how to select and highlight multiple rows in a DataGrid. My DataGrid is part of a Web User Control which is contained in an ASPX page. I haven't been...
8
10364
by: Jason L James | last post by:
Hi all, does anyone know if I can create a dataview from multiple datatables. My dataset is constructed from four separate tables and then the relationships are added that link the tables...
1
915
by: Beginner | last post by:
I am a newbie in ASP.NET. I am using VB.NET to write my codes. I have a project to be done this week but I am stucked on one thing. I want to make a datagrid of a form and display the form multiple...
0
7231
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,...
0
7132
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
7063
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...
0
7504
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...
0
5640
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5059
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...
0
4720
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...
0
1568
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 ...
1
773
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.