473,587 Members | 2,568 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datagrid with variable URL template

I got a response earlier, but I thought I'd bump this one to the top for a
quick answer.

Any tips, suggestions, or especially examples would be great!

It seems like I may be able to do this with a simpler approach. Here's my
current code for that column:

<asp:TemplateCo lumn HeaderText="Ite m Description">
<ItemTemplate >
<asp:HyperLin k runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.descr ip") %>' NavigateUrl='<% # DataBinder.Eval (Container,
"DataItem.node_ id", "ItemList.aspx? node_id={0}") %>'>
</asp:HyperLink>
</ItemTemplate>

Couldn't I make this the link if the field called "item" is blank, and
substitute a different link if it's not blank? I'm thinking something like
using IIF here, but I'm not sure on the syntax (I can get IIF, but how would
I test to see if my "item" column is blank?
maybe like this:

<asp:HyperLin k runat="server" Text='<%# DataBinder.Eval (Container,
"DataItem.descr ip") %>' NavigateUrl='<% # DataBinder.Eval (Container,
IIF(isNothing(D ataItem.item), "DataItem.node_ id", "DataItem.item" ),
IIF(IsNothing(D ataItem.Item), "ItemList.aspx? node_id={0}",
"ShowItem.aspx? item={0}") %>'>

Is this a valid approach?

Or is it not that simple due to the order of events. If that's the case,
could I do some substitution here and define the variable I use in the
codebehind? Any more specific suggestions based on these details? Thanks!

Matt

Steve wrote:
Go ahead and add the template column with the url control. You can
react to one of the datagrid's events in the codebehind to update the
url based on an if statement -- I think PreRender is the event name,
I did it before.
Hello. Got a question you more seasoned people would likely know.

I've got a datagrid in a web form that has a Hyperlink column. I've
got one link working with the property builder, how can I set up
another link template that would be used instead based on the value
of one of the dataset's column? (hope that makes sense). So links
are usually based on url field A using a particular format template,
but if a field in this row of my dataset is empty then I want to use
url field B and a different format template.

Thanks!


--

Matt

"Gravity. It's not just a good idea, it's the law!"
Nov 18 '05 #1
0 1527

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

Similar topics

3
45043
by: bpschmid | last post by:
Ive got a datagrid with a hyperlink column. I want to click on that column and go to another page, but here's the kicker, I need and want to pass not one, but two different query string parameters and format strings from 2 different bound columns. I know I could do this using session variables, but I really want to do it using query string...
0
2790
by: Andrea Trevisan | last post by:
That's a revival of a known thing I suppose.I hope it's useful. My problem was: I want to have a DataGrid with two Template columns: first with TextBox,second with Button.I want to fire an event from button and I want to have a reference to TextBox to make use of it.The most difficult was the reference to TextBox. This sample is taken from...
4
5966
by: Richard Roche | last post by:
Is it possible to use a drop combo instead of a text box when using the EditCommand in the Datagrid? Many table columns are bound to 'lookup' tables, user's don't care about the foreign keys, they want the text value. Any advice, samples or places to read are appreciated. Thanks.
7
1800
by: Bart Schelkens | last post by:
Hi, I have 2 more questions : 1. Can I fill a datagrid by using a DataReader or does it have to be a DataSet or a DataView? 2. In my datagrid I need to display two images and one of does images has te be a link to a new page. How would you do that ?
2
2451
by: Mortar | last post by:
i have a datagrid with 2 columns. the 1st column contains an id which will be used by the database for the selected checkbox records. the 2nd column is a template column containing a server checkbox control. where i'm at: i can retrieve a count of the selected checkboxes, but don't know how to get the related id's (in the 1st column).
2
3669
by: Luis Esteban Valencia Muñoz | last post by:
I have a datagrid that displays editable text fields (2 different price fields) and a checkbox in every row. It has a "SaveChanges" button at the bottom, which, when pressed, looks at every checkbox in the datagrid, if it is checked, it updates the corresponding rows prices. That works, no problem. What I need to do is that when a user...
3
2062
by: Øyvind Isaksen | last post by:
I have a datagrid that displays all files in a folder. It works good, but I need a extra column with a link for choosing image. As shown in the code below I have made an ItemTemplate for this, and what I need to do is to put the filename in the CommandArgument. How do I do that?? Is this the right way to do it, or is it a smarter way to put...
3
4322
by: Jl_G_0 | last post by:
Hey all, I need to add a hyperlinkcolumn to a datagrid, but the path (DataNavigateUrlFormatString) is dynamic, since the page lists files in directories. The folder name to list is stored in a variable (strPath). The code that I tried is: DataNavigateUrlFormatString='<%#strPath %>/{0}' But it says: "Databinding expressions are only...
0
2903
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string strDataValueField; string strDataTextField; public CreateEditItemTemplateDDL(string DDLName,string DataValueField,string
0
7918
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...
0
8206
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. ...
0
8340
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7967
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...
0
8220
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...
1
5713
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...
0
3840
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2353
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
0
1185
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...

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.