473,322 Members | 1,755 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.

Hiding a hyperlink in a non-databound datagrid column

I am brand new to ASP.NET and am now required to take over maintenance of a
..NET/C# web application. On one of the pages I'm working on there is a
DataGrid which has multiple columns. One of the columns is not databound and
instead has up to three hyperlinks in it (Edit, Award, and Cancel). A couple
of the hyperlinks should not be shown in certain cases. Now, mind you, I
don't know if it's being done in the way that's best to do it. It looks like
there is a "panel" being created to contain the hyperlinks that may not be
visible. I don't know why though (i.e. why not just set hyperlink's Visible
property and be done with it without a panel?). That being said, I want to
change the page so that one of the hyperlinks does not show (i.e. Visible =
False) based on a certain value for a session cookie. It's the Award link in
the code shown below from the .aspx file in question.

--- CODE BEGINS ---

<asp:TemplateColumn HeaderText="Actions">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:HyperLink id="hlEdit" runat="server" NavigateUrl='<%#
"Edit.aspx?id=" + DataBinder.Eval(Container, "DataItem.PersonID") %>'
CssClass="link-text"> <!--onMouseOver='<%# "javascript:toolTip(\"" +
DataBinder.Eval(Container, "DataItem.PersonToolTip") + "\");" %>'
onMouseOut="javascript:toolTip();">-->
Edit
</asp:HyperLink>
<asp:Panel ID="Panel1" Runat="server" Visible='<%#
Convert.ToBoolean(Convert.ToInt32(Request.Cookies["core"]["sl"]) <= 9)%>'>
<asp:HyperLink id=hlBids runat="server" Visible='<%#
Convert.ToBoolean(Convert.ToInt32(Request.Cookies["core"]["sl"]) <= 9)%>'
NavigateUrl='<%# "Award.aspx?id=" + DataBinder.Eval(Container,
"DataItem.PersonID") %>' CssClass="link-text">
Award
</asp:HyperLink>
</asp:Panel>
<asp:Panel ID="panAction" Runat="server" Visible='<%#
Convert.ToBoolean(DataBinder.Eval(Container,
"DataItem.PersonStatusCancel"))%>'>
<asp:HyperLink id="hlCancel" runat="server" NavigateUrl='<%#
"Cancel.aspx?id=" + DataBinder.Eval(Container, "DataItem.PersonID") +
"&op=cancel" %>' Visible='<%# Convert.ToBoolean(DataBinder.Eval(Container,
"DataItem.PersonStatusCancel"))%>' CssClass="link-text" >
Cancel
</asp:HyperLink>
</asp:Panel>
</ItemTemplate>
</asp:TemplateColumn>

--- CODE ENDS ---

Now, the value of the cookie, when I bring up this page, is 1 which
satisfies the condition. I guess my question is two-part: 1) What is best
way to accomplish something like this? 2) If this is best way to do it, then
what's wrong?
Nov 19 '05 #1
2 2587
On of the reasons for not using Visible is that hidden controls don't get
rendered to client. If there is something to do with hidden controls on
client side, you can't use Visible.

Eliyahu

"BobRoyAce" <bo*@omegasoftwareinc.com> wrote in message
news:R7********************@comcast.com...
I am brand new to ASP.NET and am now required to take over maintenance of a .NET/C# web application. On one of the pages I'm working on there is a
DataGrid which has multiple columns. One of the columns is not databound and instead has up to three hyperlinks in it (Edit, Award, and Cancel). A couple of the hyperlinks should not be shown in certain cases. Now, mind you, I
don't know if it's being done in the way that's best to do it. It looks like there is a "panel" being created to contain the hyperlinks that may not be
visible. I don't know why though (i.e. why not just set hyperlink's Visible property and be done with it without a panel?). That being said, I want to
change the page so that one of the hyperlinks does not show (i.e. Visible = False) based on a certain value for a session cookie. It's the Award link in the code shown below from the .aspx file in question.

--- CODE BEGINS ---

<asp:TemplateColumn HeaderText="Actions">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<ItemTemplate>
<asp:HyperLink id="hlEdit" runat="server" NavigateUrl='<%#
"Edit.aspx?id=" + DataBinder.Eval(Container, "DataItem.PersonID") %>'
CssClass="link-text"> <!--onMouseOver='<%# "javascript:toolTip(\"" +
DataBinder.Eval(Container, "DataItem.PersonToolTip") + "\");" %>'
onMouseOut="javascript:toolTip();">-->
Edit
</asp:HyperLink>
<asp:Panel ID="Panel1" Runat="server" Visible='<%#
Convert.ToBoolean(Convert.ToInt32(Request.Cookies["core"]["sl"]) <= 9)%>'>
<asp:HyperLink id=hlBids runat="server" Visible='<%#
Convert.ToBoolean(Convert.ToInt32(Request.Cookies["core"]["sl"]) <= 9)%>'
NavigateUrl='<%# "Award.aspx?id=" + DataBinder.Eval(Container,
"DataItem.PersonID") %>' CssClass="link-text">
Award
</asp:HyperLink>
</asp:Panel>
<asp:Panel ID="panAction" Runat="server" Visible='<%#
Convert.ToBoolean(DataBinder.Eval(Container,
"DataItem.PersonStatusCancel"))%>'>
<asp:HyperLink id="hlCancel" runat="server" NavigateUrl='<%#
"Cancel.aspx?id=" + DataBinder.Eval(Container, "DataItem.PersonID") +
"&op=cancel" %>' Visible='<%# Convert.ToBoolean(DataBinder.Eval(Container,
"DataItem.PersonStatusCancel"))%>' CssClass="link-text" >
Cancel
</asp:HyperLink>
</asp:Panel>
</ItemTemplate>
</asp:TemplateColumn>

--- CODE ENDS ---

Now, the value of the cookie, when I bring up this page, is 1 which
satisfies the condition. I guess my question is two-part: 1) What is best
way to accomplish something like this? 2) If this is best way to do it, then what's wrong?

Nov 19 '05 #2
huh? I'm not sure what you're saying here. Links are currently being
"hidden" right now successfully by interrogating data behind the grid (e.g.
the Cancel link) and setting Visible = False. What doesn't seem to be
working, and what I need help with, is making things invisible based on a
session cookie's value. Is that doable?
Nov 19 '05 #3

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

Similar topics

7
by: Randell D. | last post by:
Folks, I am working on a contact db using PHP and MySQL. My results so far outputs a slimed down version of records to the browser. I would like to implement a method whereby the user can...
11
by: Lorenzo Villari | last post by:
I premise I don't know C++ well but... I wondered what is this data hiding thing... I mean, if I can look at the header (and i need it beacuse of the class), then what's hidden? Can someone give...
4
by: Tero Partanen | last post by:
Hello! I'm writing about a rather peculiar problem I'm having with Access2000. I have a table in which I have created one hyperlink-type field. I have given the field a default value which is...
17
by: Bob Weiner | last post by:
What is the purpose of hiding intead of overriding a method? I have googled the question but haven't found anything that makes any sense of it. In the code below, the only difference is that...
3
by: Red | last post by:
I have a hyperlink the is "http://www.mysite.com?feild1=hello&field2=goodbye" how can i hide the variables being passed to the next page so that all that is displayed to the user is...
9
by: Leon | last post by:
What Am I Doing Wrong? Code Will Not Run, I Can't See The Error! Thanks. <asp:datalist id="DataList1" runat="server" RepeatColumns="4"> <ItemTemplate> <asp:HyperLink id=HyperLink1 ImageUrl=...
2
by: Xerxes | last post by:
Hi, I am trying to hide/change the window.status text when the mouse is over the hyperlink text but it does not seem to work on Mozilla (Firefox). Am I doing something wrong: <a...
7
by: mathieu | last post by:
Hello, I did read the FAQ on template(*), since I could not find an answer to my current issue I am posting here. I have tried to summarize my issue in the following code (**). Basically I am...
2
by: subramanian100in | last post by:
Is my following understanding correct ? Data abstraction means providing the interface - that is, the set of functions that can be called by the user of a class. Information hiding means...
2
by: =?Utf-8?B?Q2hhcnRz?= | last post by:
I have been writing C# programs to spider yellow page to get list of restaurant name, address to the database. When I encounter button or hyperlink, I don’t know how to use the program to click...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
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...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.