Control Gridview Visibility Using Javascript?

Jun 19, 2010

I have a gridview and I have to control the visiblitiy of the grid columns using javascript. Consider this gridview. I have a few columns.

<asp:GridView ID="grdTest" runat="server" AutoGenerateColumns="False" Width="100%">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkResource" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Resource">
<ItemTemplate>
<asp:Label ID="Resource" Text='<%# Bind("Resource") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Description" HeaderText="Resource Description" HtmlEncode="false">
<ItemStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Center" />
</asp:BoundField>
</asp:TemplateField>
</Columns>
</asp:GridView>

I can control the visibility of these columns at the server side by using this -

grdTest.Columns[n].Visible = false;

But, I have to control the visibility from the client side using javascript. I tried a lot but I was only able to access either the row object or any particular cell of the gridview.

grid.rows[index].cells[i].style="display: none"; //for cell

Is there a way to access the column object of the gridview and control its visibility using javascript?

View 1 Replies


Similar Messages:

Client Side Javascript Call From Control Doesn't Reset Visibility?

Jan 3, 2010

I have a javascript to enable text boxes when called, I want to trigger this code when a user picks value "Custom" from a dropdownlist, so that I can display/Hide these new textboxes.

function setVisibility(DropDownListID) {
var element = document.getElementById(DropDownListID);
var element1 = document.getElementById("TestBox1");
if (element.value == "Custom") {
element1.visible = !element1.visible ;
}
<asp:DropDownList ID="DateRangeDropDownList" runat="server" Enabled="True" onChange="setVisibility('DateRangeDropDownList');">
<asp:ListItem>Some Value</asp:ListItem>
<asp:ListItem>Custom</asp:ListItem>
</asp:DropDownList>
<asp:TextBox ID="TestBox1" runat="server"></asp:TextBox>

For some reason it doesn't seem to work.

View 1 Replies

Setting Visibility Of Button Control In GridView Header?

Nov 8, 2010

I have a gridview that displays entries from a data table. I am giving users the ability to select a subset of the data in the table by having a textbox and search button in the grid view header. The search button fires the gridview row command, and changes the underlying sqlDataSource's select command, and adds the text value from the text box as a parameter.

Also, I have a "Show All" button in the header, that clears out the select parameters, so all entries in the table are shown. Again, this works perfectly.

What is NOT working is controlling the visibility of the "Show All" button control. Below is the html markup for the data grid header template:

<HeaderTemplate>
<asp:Button ID="btnShowAll" runat="server" CausesValidation="False" CommandName="ShowAll" Text="Show All" />
<asp:Button ID="btnSearch" runat="server" CausesValidation="True" CommandName="Search" Text="Search" ValidationGroup="vldSearch" /><br />
<asp:TextBox ID="txtSearchName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="vldSearchName" runat="server" ErrorMessage="You have to provide an attorney name to search for." Text="*" ControlToValidate="txtSearchName" ValidationGroup="vldSearch" ForeColor="White"></asp:RequiredFieldValidator>
</HeaderTemplate>

In the Row Command event handler, here is how I am setting the visibility of the button:

If Not Me.dgAttorneys.HeaderRow Is Nothing Then
Dim btnShowAll As Button = Me.dgAttorneys.HeaderRow.FindControl("btnShowAll")
btnShowAll.Visible = Me.sqlAttorneys.SelectParameters.Count > 0
Trace.Write("Show all status is " & btnShowAll.Visible.ToString)
End If

The trace statement is showing the correct visible status - if the "show all" button is clicked, I do a SelectParameters.Clear() on the sqlAttorneys sqlDataSource.

Is my problem due to a misunderstanding of how the "FindControl" method works - I had assumed my new btnShowAll that I define is actually a reference to the "physical" control on the aspx page, so any changes I make to my local object is reflected in the control on the page.

If this is not the case, what is the best way to get a reference to the button control in the header row of the grid view?

View 1 Replies

How To Toggle Visibility Of Combobox With Javascript Or Jquery

Feb 28, 2011

I have a set of server side combo boxes in a table. Based on client events, I need them to appear or disappear. I've tried the following with no success:

document.getElementById("cboToothNumber").style.visibility = "hidden";

$("#cboToothNumber").hide()

View 2 Replies

Tie The Visibility Of A Pane To Another Control?

Jan 16, 2010

So I have a two radio buttons. If RadioButton1 is selected, I want Panel1 to be visible and Panel2 to be hidden. If RadioButton2 is selected, I want Panel2 to be visible and Panel1 to be hidden. Is there a way to do this without requiring a postback?

View 2 Replies

AJAX :: Disable Tab Or Visibility Control

Aug 18, 2010

How to disable tab or visibility control if some condition is not satisfy.

I want it that control in .asmx page, because I have some Cascaded combo under two tab.

If the first combo is not populate in any of tab then that tab will not visible or disable to user.

As I am populating the cascaded combo box using web methods so it is easy for me to declare that fuction there.

View 7 Replies

Web.sitemap - Roles Do Not Seem To Control Visibility?

Mar 22, 2010

I have a (simple) sitemap and am trying to figure out why a certain sub-menu is always visible.

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Login.aspx" title="Home" description="RivWorks" roles="*">

[code]...

I have a main menu option of "Dashboard". Under this menu item I have 2 options: 1) Campaign Manager & 2) Negotiation Manager. Now, what is interesting is when I am in either the campaigns role OR the auto-negotiation role I see the Dashboard and BOTH sub-menu items. This is not the behavior I expected. I expect to only see both sub-menus when I am in the campaigns role AND auto-negotiation role. The OR scenario should give me the Dashboard menu item and one OR the other sub-item...Am I doing something wrong here or thinking a wrong way?

View 1 Replies

Cannot Change Control's Visibility On C# Code

Oct 5, 2010

I want to change controls visibility on c#, but nothing happens. The controls are in an AspxPopupControl and 3 of them are hidden in design time, 1 of them is visible. I use this code to visible them

if (paramType == "Grup")
{
gv_Answers.Visible = false;
trlGroup.Visible = true;
chkShowItems.Visible = true;
}
else
{
gv_Answers.Visible = true;
trlGroup.Visible = false;
chkShowItems.Visible = false;
}

This code is in a CustomCallBack event of a gridview. So i don't know what to do from this point. It's an easy task but i couldn't handle it.

View 3 Replies

Repeater Template Sub - Control Visibility Before Databind

Jul 1, 2010

I have a custom control which contains a Repeater control. The Repeater has an ItemTemplate. Inside that item template I have a panel which is going to hide something based on "IsEditable" a boolean property of the custom control. What I would like to do is set the panel's visibility once before the Repeater is databound.

I know I could do an onItemDataBound event and use FindControl to get the panel but that seems a little excessive since it will always be either visible or not for all rows and I have no other actions that need to occur on databind. Is there a way to find the control in the ItemTemplate before the Repeater is databound?

View 1 Replies

Ajax UpdatePanel Child Control's Visibility

Jan 17, 2011

I want to change the visibility of two asp.net image controls (runat="server") at the beginning and the end of the method call duration. I mean, I want the first image displayed and second one remains hidden until the last line of my method, which in turn, the second image becomes visible and the first one hides. I've put the area of the triggering control in updatepanel and have declared triggers of the updatepanel; But when I press the control (which is a button), the image at the end of the process is displayed correctly and on time but the one which should be displayed in the first line of the method is not displayed. I've configured my updatepanel to use conditional update mode and have used these lines for my intention:

imgLoading.Visible = true;
..
rest of the process
..
if (true)
{
imgLoading.Visible = false;
imgSuccess.Visible = true;
}

View 1 Replies

AJAX :: Label Visibility With AsyncFileUpload Control?

Jul 26, 2010

so here is what i've got:

-master page with updatepanel - within the update panel is a contentplaceholder
-aspx page that uses the master page which contains aysncfileupload,a button,an image,and a label

what i'm trying to accomplish:

when a user uploads a file using the asyncfileupload it gets saved to a public folder.-this works as it should when the user presses the button the file is processed and should display the image and label (which were previously not visible)-this does not what happens is that the file gets processed but the image and label stay hidden,and i cannot figure out why.here's the aspx page and code snippets:

[Code]...

the file gets uploaded,and it even hits the two lines which should make the label and image visible but they stay hidden.i know that if you try to change controls with the afuExcelUsers_UploadedComplete event,they will not happen since the asyncfileupload only does a partial postback. this is why that event (afuExcelUsers_UploadedComplete) only saves the file on the server.then pressing the button triggers a different event and should do a "postback" and have control over the label and images visibility and other properties.

View 1 Replies

Web Forms :: Proper Syntax For Checking Visibility For A Control?

Feb 28, 2011

I get an error using [Code]....

View 6 Replies

How To Change The Visibility Of A Hyperlinkfield In A Gridview

Jan 27, 2010

I have a gridview with some data and two hyperlinkfields.I want to make the first hyperlinkfield of the first row not visible and the second hyperlinkfield of the last row not visible.this what I did till now

Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If e.Row.RowType = DataControlRowType.DataRow Then[code]....

This will work only for the first hyperlinkfield.Omitting the comments will make the first hyperlinkfield not visible for all rows.

View 3 Replies

GridView Conditional Button Visibility?

Mar 28, 2011

I have this itemtemplate for a gridview column that is pulling data from a SQL database. My Question is how would I perform a check to see if my field ActivityFile has a value (which means a file is in the db) and then display the LinkButton at which point I generate code to download the file (already done and works).

<ItemTemplate>
<asp:LinkButton ID="DownloadFileBtn" runat="server" visible="false">Download File</asp:LinkButton>
<br />
<a href="<%# Eval("ActivityLink") %>"><asp:Label ID="Label4" runat="server" Text='<%# Bind("ActivityLink") %>'></asp:Label></a>
</ItemTemplate>

View 1 Replies

Using Calender Control - Change Visibility On Button Click Event

Sep 4, 2010

I am using calender control I want to change it's visibility on button click event. This is my form design:

<form id="form1" runat="server">
<asp:Calendar ID="Calendar1" runat="server" Visible="False"></asp:Calendar>
<asp:Button ID="Button1" runat="server" Text="Show" />
</form>

View 1 Replies

Web Forms :: How To Programmatically Control Individual Menu Item Visibility

Nov 5, 2010

I would like to programmatically hide/unhide Individual Menu items.

How is this best accomplished. I see that intellisense does not have a visibility attribute for Menu1.Items(1).

View 4 Replies

Set Textbox Visibility Based On Dropdownlist Value In Gridview?

Aug 27, 2010

I have a gridview that i would like to show or hide a text box based on the selected value of a dropdownlist on the same row.

My gridview:

[code]...

Edit:

I would also like to be able to use a required field validator on the textbox if it's not hidden.

View 1 Replies

Web Forms :: How To Control Visibility Of Menu Nodes Depending On User Role

Apr 16, 2010

I have a Menu control in MasterPage based on web.sitemap file. My website has roles enabled (AspNetWindowsTokenRoleProvider) and uses Windows authentication mode. So, user has to be in a specific Windows Group to be able to access the site. I need to allow some users to see all menu nodes and some restricted set of nodes. How do I do that?

I would like to be able to create, say following Windows groups:

domain_namemy_app_users
domain_namemy_app_superusers
domain_namemy_app_admins

and code sitemap nodes this way:

<siteMapNode url="~/MOC_Masterdata_MOC_Approvers_Plain.aspx" title="MOC Approvers" description="MOC Approvers" />

View 5 Replies

Forms Data Controls :: LinkButton Visibility Inside A Gridview?

Jun 9, 2010

I am new to C# and I have a LinkButton inside a gridview. I have been trying to set the myLinkButton.Visible property true or false depending on a database entry.Here is the code behind I have been working on:

protected void gvBalance_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)

[code]...

View 8 Replies

C# - Show / Hide Using Javascript On A Control Inside A ASCX Control In A Gridview

Oct 8, 2010

I have written a web usercontrol (ascx). Inside, there is a Panel that I want to show/hide on click of a hyperlink inside the usercontrol.

Normally, this is easy just by doing something like this (the onclick attribute is added to the hyperlink on prerender):

var PanelToShow = document.getElementById('<%=PanelInvoiceHasBeenCreated.ClientID %>');
if (PanelToHide != null) {
PanelToHide.style.display = 'none';
}

but because the ascx control is held within the gridview, the above will assess all the controls (of which there are many in the gridview) with the name 'PanelInvoiceHasBeenCreated'. The only time it will work is when there is 1 row in the gridview. Currently, with my existing code, if I click the hyperlink in any row, it shows/hides the panel in the bottom row of the gridview!

Therefore, my question is how do I get the actual, unique ID I need to show/hide on the correct control in the correct row?

View 2 Replies

Forms Data Controls :: Gridview Column Changing Visibility Depending On A Row.text?

Oct 18, 2010

[Code]....

and im not getting the result i expected =

View 5 Replies

Forms Data Controls :: In Gridview Item Template - Controlling Visibility Of Linkbutton And Label

May 16, 2010

[Code]....

[Code]....

<%@ Page Title="" Language="VB" MasterPageFile="secureds_deals.master" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<script runat="server">
Protected DealId As Integer = 0
Protected DealName As String
Protected StartDate As Date
Protected ContractDate As Date
Protected ClosingDate As Date
Protected SubmitRole As String
Protected Status As String.......

View 6 Replies

How To Get Gridview Textbox Control Id In JavaScript

May 11, 2010

Currently I'm working on gridview it's have textbox on submit click I want to get textbox id of gridview but I an unable to find it button submit.

View 3 Replies

How To Get Control In A Gridview Cells With Javascript

Aug 31, 2010

how can i access the controls in a gridview cells in which i use for inline edit? In the gridview, there would be two controls in a cell, which is a label and a textbox. When user navigate around the gridview, next cell would turns textbox become visible and label become invisible. How can i enhance the code below. I'm not familiar with javascript,

function NavigateCell() {
if (event.keyCode == 37) { //to the left
if (currentCellReference.previousSibling.cellIndex != 0) {
currentCellReference.style.borderWidth = 1;
[code]...

View 1 Replies

AJAX :: Two Update Panels Interfacing With External Button - How To Control Button Visibility

Jun 15, 2010

I have a page with 2 update panels

UpdatePanel1 contains a gridview1 and a standard panel, pnlForms. gridview1 has a linkbutton which is processed in the gridview1_rowcommand

UpdatePanel2 has gridview2.

There is also a Submit button that isn't in either UpdatePanel but may be a candidate to go into its own UpdatePanel. The Submit button is a trigger for both update panels

The behavior I would like is:

1-Initially, all visible except pnlForms and Submit button 2- When linkbutton in UpdatePanel1 gridview1 is clicked, pnlForms and Submit button become visible. 3. When Submit button is clicked, both gridviews should be refreshed, and PnlForms and the Submit button should both become not visible. I believe I may have to put the Submit button in its own UpdatePanel3 but am not sure how to proceed.

In my present code, everything works as desired except Submit button (not presently in any Update panel) is always visible. Assuming Submit button is initialized to not visible, how do I get it to appear when I click the link button in gridview1 and to disappear when it is clicked?

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved