473,322 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

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:TemplateColumn HeaderText="Item Description">
<ItemTemplate>
<asp:HyperLink runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.descrip") %>' 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:HyperLink runat="server" Text='<%# DataBinder.Eval(Container,
"DataItem.descrip") %>' NavigateUrl='<%# DataBinder.Eval(Container,
IIF(isNothing(DataItem.item), "DataItem.node_id", "DataItem.item"),
IIF(IsNothing(DataItem.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 1516

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

Similar topics

3
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...
0
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...
4
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,...
7
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...
2
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...
2
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...
3
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...
3
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...
0
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.