nettiers and gridview

hi, i have already binded a gridview and the data.
in my aspx i have something like that:
<asp:TemplateField><HeaderTemplate>Select</HeaderTemplate>

<ItemTemplate>

<asp:HyperLink id="SelectLink" runat="server" NavigateUrl='<%#
"~/patientBook_step2.aspx?idtreatment=" + Eval("IDTreatment") +
"&idpatient=" + Request.QueryString["id"]%>'><img border='0'
src='App_Themes/AdXToDefault/Images/16x16/flag.png'></asp:HyperLink>

</ItemTemplate>

and now what i want to do is to show or to not show the hyperlink depending
on the value of another field (like 'active' or something like that).

how can i do that?
thank you!
Gabriel Pineda [ Di, 08 April 2008 05:45 ] [ ID #1937717 ]

Re: nettiers and gridview

In your code-behind, I'd recommend adding a RowDataBound event that sets
the Visible property of your SelectLink to false based on whatever column/field
you're interested in. The e.Row.Cells[index] would be based on the column
order of your grid.

ex:

protected void ExampleGrid_RowDataBound(object sender, GridViewRowEventArgs
e)
{
if (e.Row.Cells[3].Text == "Inactive")
{
((HyperLink) e.Row.FindControl("SelectLink")).Visible = false;
}
}

HTH.

-dl

--
David R. Longnecker
http://blog.tiredstudent.com

> hi, i have already binded a gridview and the data. in my aspx i have
> something like that:
> <asp:TemplateField><HeaderTemplate>Select</HeaderTemplate>
>
> <ItemTemplate>
>
> <asp:HyperLink id="SelectLink" runat="server" NavigateUrl='<%#
> "~/patientBook_step2.aspx?idtreatment=" + Eval("IDTreatment") +
> "&idpatient=" + Request.QueryString["id"]%>'><img border='0'
> src='App_Themes/AdXToDefault/Images/16x16/flag.png'></asp:HyperLink>
>
> </ItemTemplate>
>
> and now what i want to do is to show or to not show the hyperlink
> depending on the value of another field (like 'active' or something
> like that).
>
> how can i do that?
> thank you!
dlongnecker [ Di, 08 April 2008 17:41 ] [ ID #1937784 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » nettiers and gridview

Vorheriges Thema: How to assign Text and 'hidden' record ID to a checkbox control?
Nächstes Thema: Button Click Event fired on second press?