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!"