473,405 Members | 2,379 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,405 software developers and data experts.

how to show/hide gridview Columns using javascript

--This is the html code
Expand|Select|Wrap|Line Numbers
  1. <body>
  2.     <form id="form1" runat="server">
  3.         <div>
  4.             <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
  5.                 <Columns>
  6.                     <asp:TemplateField HeaderText="Agent Name">
  7.                         <ItemTemplate>
  8.                             <asp:Label ID="lblagentname" runat="server" Text='<%#Bind("AgentName") %>'></asp:Label>
  9.                         </ItemTemplate>
  10.                     </asp:TemplateField>
  11.                     <asp:TemplateField HeaderText="Agent Amount">
  12.                         <ItemTemplate>
  13.                             <asp:Label ID="lblagentAmount" runat="server" Text='<%#Bind("AgentAmount") %>'></asp:Label>
  14.                         </ItemTemplate>
  15.                     </asp:TemplateField>
  16.                 </Columns>
  17.             </asp:GridView>
  18.             &nbsp;<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button"/>
  19.             </div>
  20.     </form>
  21. </body>
  22.  
----This is the csharp code
Expand|Select|Wrap|Line Numbers
  1. public partial class GridValidation : System.Web.UI.Page
  2. {
  3.     protected void Page_Load(object sender, EventArgs e)
  4.     {
  5.         DataTable dt = new DataTable();
  6.         dt.Columns.Add("AgentName", typeof(string));
  7.         dt.Columns.Add("AgentAmount", typeof(string));
  8.         dt.AcceptChanges();
  9.  
  10.         DataRow dr = dt.NewRow();
  11.         dr["AgentName"] = "shashikesh mishta";
  12.         dr["AgentAmount"] = "1000";
  13.         dt.Rows.Add(dr);
  14.  
  15.         DataRow dr1 = dt.NewRow();
  16.         dr1["AgentName"] = "HAVAK";
  17.         dr1["AgentAmount"] = "10001";
  18.         dt.Rows.Add(dr1);
  19.         dt.AcceptChanges();
  20.  
  21.         GridView1.DataSource = dt;
  22.         GridView1.DataBind();    
  23.  
  24.     }
  25.     protected void Button1_Click(object sender, EventArgs e)
  26.     {
  27.        //so on this button click(on client click) i want to hide "Agent Amount"
  28. //coumn
  29.  
  30.     }
  31. }
Jul 24 '07 #1
3 8426
gits
5,390 Expert Mod 4TB
hi ...

welcome to TSDN ....

please post some example-code or a link to a test-page ...

kind regards
Jul 24 '07 #2
pbmods
5,821 Expert 4TB
Heya, mudassir368.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Jul 24 '07 #3
Heya, mudassir368.

Please use CODE tags when posting source code. See the REPLY GUIDELINES on the right side of the page next time you post.

What do you want your code to do? Give an example.
What is your code doing that you don't want it to do? Give an example.
What is your code *not* doing that it is supposed to? Give an example.
Hi pbmods,
Right Now My Code is Displaying A gridView with Two Columns
One is "Agent Name" and other is "Agent Amount"
i want a javascript function which will be called on Button1 Click
and it will hide Agent Amount Columns and show only one column
that is Agent Name
This can be easily Done on serve side code
but i want it to be done on client side code
Jul 25 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Aws | last post by:
My crazy GridView !! I am using Visual Studio 2005, I have a problem with my GridView. I have one access .mdb table and when I update a record on the table EVERYTHING is perfect. I made a Web...
2
by: Kamen | last post by:
Hello there, I try to define the properties font-size and font-bold of the pager of a gridview using the pagerstyle, but the settings are not appleyd at run time. What could be the reason for...
3
by: | last post by:
I'm using the DataList and GridView controls, and I am trying to wrap my head around the problem of conditionally showing or hiding cells/cell content based on the presence or absence of DB data. I...
9
by: ghostwolf | last post by:
Hi, I want to hide a column in the asp:GridView, say one of the column of asp:BoundField. But it is not allowed to put <divinside for setting it display:none. What can I do? Thanks in millions.
0
by: Riaaaa | last post by:
I have created the form for entering the company details with its general information in asp.net C# 2005. I have two buttons that form on the submit click event it should saw the newly / last...
4
by: Luqman | last post by:
I have populated the Child Accounts and Parent Accounts in a Grid View Control, I want to hide the Select Column of Parent Accounts, but not the Child Accounts, is it possible ? I am using VS...
0
by: gnewsgroup | last post by:
Well, I am trying to use the footer row of a GridView for insertion purpose. There are some articles about this, for example, the gridviewguy.com has an example, which always displays the footer...
18
by: Liquidtouch | last post by:
I have been searching on this for awhile and cant find anything and playing around with it got me no where. I will start with what I am after and then explain what I have. I have a table with 3...
4
by: Peter | last post by:
I want to call a JavaScript on PageIndexChanged event, how do I do that? Thank You Peter
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.