473,320 Members | 2,146 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,320 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 8417
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
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...
1
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.