Setting visible property of a panel control inside of a template column

In my DataGrid I have one column template. In the template I have two panel controls. If there is no data in the dataset for pnlLink2 then I want to set pnlLink2.Visible = true. How can I do that?

I have this so far
if (LinksDataSet(renumber).Tables[0].Rows[0]["link_name1"].ToString() == null
{
// Hide pnlLinks2
}


<asp:templatecolumn>
<itemtemplate>
<asp:panel id="pnlLink1" runat="server">
<asp:hyperlink id=link1 runat="server" text='<%# DataBinder.Eval(Container,"DataItem.link_name1") %>' navigateurl='<%# DataBinder.Eval(Container,"DataItem.link_url1") %>'>
</asp:hyperlink>
</asp:panel>
<asp:panel id="pnlLink2" runat="server"><br>
<asp:hyperlink id=link2 runat="server" text='<%# DataBinder.Eval(Container,"DataItem.link_name2") %>' navigateurl='<%# DataBinder.Eval(Container,"DataItem.link_url2") %>'>
</asp:hyperlink>
</asp:panel>
</itemtemplate>
</asp:templatecolumn>

0
joee
10/6/2003 9:52:11 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

2 Replies
883 Views

Similar Articles

[PageSpeed] 46

You can do it like this possibly:

<asp:panel id="pnlLink2" runat="server" visible='<%# HidePanel(Container.DataItem("link_name2")) %>'>

Code Behind:
Function HidePanel(YourColumnValue As String) As String

If YourColumnValue = YourConditionToHide Then
Return "True"
Else
Return "False"
End If

End Function

let me know if that works.
0
Intrino
10/7/2003 1:39:13 AM
Yes this worked, using C# I did something like this:


<asp:panel id="pnlLink1" runat="server" visible='<%# HidePanel(DataBinder.Eval(Container,"DataItem.link_name1").ToString()) %>'>
Then in the code behind:
public bool HidePanel(string colValue)
{
if (colValue == "")
{
return false;
}
else
{
return true;
}
}

I did figur out another way, see below, but this is soooooo much cleaner. Thanks for the idea!!!

private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.EditItem)
{
if (LinksDataSet(renumber).Tables[0].Rows[0]["link_name1"].ToString() == "")
{
e.Item.FindControl("pnlLink1").Visible = false;
}
else
{
e.Item.FindControl("pnlLink1").Visible = true;
}
}
}
0
joee
10/7/2003 2:12:46 PM
Reply:

Similar Artilces:

Set Focus to a control inside a panel with scrollbars while the control is not in the visible area of the panel
Hello, I have a little problem setting the focus to a control. On my page there is a panel with auto scrollbars. Inside these panel I place Controls, which I add dynamicaly on page load event . After adding several controls to the panel I have to set the focus to a special control I placed on the panel. That is no problem until the auto Scrollbars kick in and the control I have to set the focus to is gets out of the visible area of the panel. Can anyone tell me please how to move the scrollbars of the panel by code or how to set the focus to my control   Thanks   RITC Just ...

Set the property of a server control inside a user control inside a Master Page
How do you set the property(ForeColor) of a server control(lnkInquiryReport2) located in a user control (LeftNavMain1) within a Master Page (default.master)? On the user control, expose a property of type color and bind this to the forecolor for the hyperlink control [keep some default value]. On your master page expose the user control as a property. On your content page, access the uc via the master's prop and the forecolor prop via the uc's prop and set it. Instead of exposing the uc from the master, you can also find the uc on the master - cast it to the correct type and then access th...

Wizard Control
Hi All, I have simple wizard control. The first step contains checkboxes and depending upon which checkboxes were selected, I want hide (skip) steps in wizard control. I am using <code>ReportDataWizard.WizardSteps[1].Visible = true</code>  but getting following error. Please help.  The Visible property of a View control can only be set by setting the active View of a MultiView. Hi,See this quickstart tutorial http://quickstarts.asp.net/QuickStartv20/aspnet/doc/ctrlref/standard/wizard.aspx Specifically look at the section Wizard NonLinear Navigationand Sc...

Visibility control of Panel control and its affect on data controls
Thought I would toss this out here this morning and perhaps someone else had run across the same issue and had found a good way to accomplish what I want. First let me state what I'm attempting to do and the problem that I've run into.  GridView1 has a collection of rows in a SQL table that I want to present to the user. I've provided them the options of sorting and selecting only from the GridView control.  Orgionally, I had created a detail view that was being presented in Edit mode and then customized the layout of the edit item template to suit my needs.&nbs...

How to set focus in a control inside Collapsible Panel Control
I am using Collapsible panel Control and inside Contentpanel I have a textbox into which I want to set the focus.  ScriptManager.SetFocus(Textbox1) does not work   Could someone help please?   Thanks, Rupen I found that there is some patch available to fix this issue. http://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=6986  But I do not know how to apply this. Could someone tell me?     Hi Rupen, From the url provided above, I have found a sample with the name "FocusCollapsibelPanelExtender.zip " under "F...

AJAX: which is better more controls inside one update panel or few controls inside more update panels
hi in form that have many controls , gridview , formview, buttons, textboxes, etc. which is better, put them all in one update panel, or few controls in more update panels? i.e. gridview , formview, buttons, textboxes all in one update panel or gridview in update panel, formview in updat panel, buttons (that text needs to change based on some business rules) in update panel, etc? besides will tables and divs inside update panel affect AJAx performance?! Hi,    Putting too many controls in an update panel will certainly affect the performance. I have certainly faced it. ...

How do I set the visibility property on a control in a user control from the host web page?
I have a user control with a few web controls like text boxes.  I want to show or hide one of the text boxes on the user control based on a variable posted to the page hosting the user control.  There may be multiple instances of the user control but they will all behave the same.  In the code behind, how do i set the text box on the user control to visible = "false" or visible = "true"?  Please provide an example as well as an explanation.Thanks! Set it from the web form by using a public property exposed on the user control. See An Extensive E...

Using a templated control inside a databound templated control
Hi,  We have a large number of pages that display contents in a simple header - content combination. To facilitate styling, we have created a custom control 'ContentArea' that exposes two template properties: HeaderTemplate and ContentTemplate. These allow a designer to define the layout for the header and content in the aspx file. In addition, two themable properties named HeaderCssClass and ContentCssClass allow the definition of a Css class for both texts. Like this, using theming, defining the style of our site contents becomes extremely simple. As an exampl...

Setting a panel control's visibility and it's affect in nested controls.
I am trying to debug a page using the panel control.  The code in the final submission of the form has logic to get data from a dropdown based on the control's visibility.  If the control's visibility is set to true, the the data is retrieved and sent to the database.The problem appears to be the dropdown control's visibility is set to false when it should not.  The dropdown is nested in a panel control.  While doing a trace, it appears when a panel control's visibility is set to false, the visibility for all controls nested under this panel are set to false as well.You'r...

Collapsible panel control inside another collapsible panel control
I have a sidebar panel on my page that is shown/hidden by the collapsible panel.  In the panel I have smaller user controls that contain various bits of data.  I would like to individually collapse those when the main sidebar panel is expanded.  Is this possible?  Hi Ken6554, You should nest another CollapsiblePanelExtender (or Accordion) inside the panel.    Best regards, JonathanJonathan ShenMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help. Jonathan Shen – MSFT:H...

controls not visible inside formview control
I am trying to write a query to select data from one table based on the resultof a drop down list that pulls data from another table. The query I am writing is: "SELECT church.churchName, church.churchId AS Expr1 FROM [churches]WHERE ([deanery.deaneryId] = @churches.deaneryId)"I am using a sql source controlNow I found an example from a website that pulls data from one drop down list and usesthe selected value to populate the second drop down list. But, the controls are not part of a formviewcontrol. So my question is how do I get the dropdownlist control that is located...

Properties of Controls within a Panel Control
I am trying to access the properties of ImageButton controls that I have programatically created inside a Panel control. I could reference them using "panel.controls.item(x)" - but how would I reference the properties specific to the ImageButton? Thanks, Jay Hi, You need to use it in the for loop as follows for each c in panel.controls.count if c.type ="ImageButton" then ...... end if next Hope it gives you an idea Have a Great DayRegardsRamu...

How can we access a control outside the update panel with an control inside the update panel
Take a very simple example, i have a button inside the update panel along with other controls and i have a textbox on the page.What i want is that when i click the button inside the update panel,it should update the textbox which is present outside the update panel.How can i do this?Prakash kumar To my knowledge you cannot update any control outside of the update panel.  If you want to update the control move it inside the update panel. Do you want to modify the text box with server-side code? If so, put it in its own UpdatePanel. Set the UpdateMode on the panel to Conditional. Then...

Getting 'System.Web.UI.Control' does not contain a definition for 'DataItem' error on controls when placed inside an update panel which is in a template.
Using the June CTP, I;ve got an updatepanel inside the itemtemplate of a datalist which is now suppopsed to be supported (it works). I also have some asp controls (imagebutton, label) which get their values dynamically (DataBinder.Eval(Container.DataItem, "fieldname").ToString(). This would work fine before putting the updatepanel in the datalist itemtemplate, I now get the error in the title when building ('System.Web.UI.Control' does not contain a definition for 'DataItem') for each control... How can I dynamically assign the values to the controls in the datalist when also using upd...

Web resources about - Setting visible property of a panel control inside of a template column - asp.net.presentation-controls

Property - Wikipedia, the free encyclopedia
This article may require copy editing for grammar, style, cohesion, tone, or spelling . You can assist by editing it . In abstract, property ...

Property - Wikipedia, the free encyclopedia
In abstraction, property is that which belongs to or with something, whether as an attribute or as a component of said thing. For the significant ...

Chinese property firm Yuhu hires ex-deputy premier Andrew Stoner
A Chinese-based property firm that has donated hundreds of thousands of dollars to Australian political parties has added former deputy premier ...

How property developers make windfall millions
Buy one thing, use spin and insider knowledge to get planning approval to turn it into something completely different and, hey presto, you've ...

Mt Maunganui property home of the year - The Courier-Mail Search Search
A LUXURY beachside home in Mt Maunganui and a renovation in Auckland have won supreme awards at New Zealand's 25th Registered Master Builders ...

Treasurer Scott Morrison orders forced sale of $10m of property
Foreign investors who have bought established residential real estate without notification given until end of month to declare purchases.

Property estates on former Perth school sites popular with buyers
CRAIGIE, about 24km from the CBD, is the site of Perth’s latest residential school conversion. The first 22 blocks at the site of the former ...

Property estates on former Perth school sites popular with buyers - PerthNow Search Search
CRAIGIE, about 24km from the CBD, is the site of Perth’s latest residential school conversion. The first 22 blocks at the site of the former ...

When Lang Walker is selling property, the RBA should be worried
If one thing has distinguished Lang Walker, it's been his ability to sell out at the right time. Lang Walker knows a bit about property development ...

Chinese property firm Yuhu hires ex-deputy premier Andrew Stoner
A Chinese-based property firm that has donated hundreds of thousands of dollars to Australian political parties has added former deputy premier ...

Resources last updated: 12/4/2015 8:17:18 AM