473,396 Members | 1,929 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,396 software developers and data experts.

how to hide a column in a datagrid but autogenerated columns = "True"?

Hi Frnz,

How to hide a column in a datagrid but, the property named Autogenerated Columns = "True". b'coz i want to add a datacolumn dynamically....... My Question is how to hide that columns??????
Sep 27 '10 #1

✓ answered by Plater

DataGridColumns have a .Visible property, try setting it to false

5 5285
mzmishra
390 Expert 256MB
Expand|Select|Wrap|Line Numbers
  1. DataTable dt new DataTable();
  2.  
  3. DataColumn dcol new DataColumn(ID typeof(System.Int32));
  4.  
  5. dcol.AutoIncrement true;
  6.  
  7. dt.Columns.Add(dcol);
  8.  
  9.  
  10.  
  11. dcol new DataColumn(NAME typeof(System.String));
  12.  
  13. dt.Columns.Add(dcol);
  14.  
  15.  
  16. //Iterate through the columns of the datatable to set the data bound field dynamically.
  17.  
  18. foreach (DataColumn col in dt.Columns)
  19.  
  20. {
  21.  
  22.  
  23. BoundField bfield new BoundField();
  24.  
  25. bfield.DataField col.ColumnName;
  26.  
  27. bfield.HeaderText col.ColumnName;
  28.  
  29. GrdDynamic.Columns.Add(bfield);
  30.  
  31. }
  32.  
  33.  
  34. GrdDynamic.DataSource dt;
  35.  
  36. GrdDynamic.DataBind();
  37.  
  38. }
Sep 27 '10 #2
Plater
7,872 Expert 4TB
DataGrid or DataGridView or GridView?
DataGridView and GridView you can hide the columns after applying a datasource.
I've never used the DataGrid object
Sep 27 '10 #3
Hi Frnz,

How to hide a column in a datagrid but, the property named Autogenerated Columns = "True". Because I want to add a datacolumn dynamically... My Question is how to hide that columns?
Oct 6 '10 #4
Plater
7,872 Expert 4TB
DataGridColumns have a .Visible property, try setting it to false
Oct 6 '10 #5
First Thanks for ur response,i tried to do the following code. It helps more......

DataSetname.Columns.Remove("ColumnName");

Thanks,
Sri Devi S
Oct 8 '10 #6

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

Similar topics

9
by: lawrence | last post by:
In the following loop, at the end, the method debugNotes() is printing out some notes for me to read, so I can figure out what is going on in my script. Where I try to print out the value of the...
1
by: nick | last post by:
Hi What is the proper way of setting a boolean column (checkbox) to "true" by default? It seems that the datagrid won't accept inserts if the default is true. BoolColPaid = new...
4
by: Bradley Plett | last post by:
I have what should be a trivial problem. I am using XMLSerializer to serialize an object. It serializes boolean values as "True" and "False". I then want to use an XSLT on this XML, and I want...
2
by: Guy Lafleur | last post by:
I have a user control that builds a treeview dynamically in the Page_Load event. Also, I have the AutoEventWireup property set to true (i.e., <%@ Control AutoEventWireup="true" %>). Then, when I...
2
by: G Dean Blake | last post by:
I have a textbox in an ItemTemplate of a grid I'm using to allow users to change a value. I've done it a hundred times. In this project I have it returns the original amount even though the user...
0
by: Sachin | last post by:
Hi All, I am using ASP.NET 2.0 and GridView control. I have a stored procedure, SP_GetAllRows which takes the table name as parameter and fires the query "Select * from TableName" dynamically....
3
by: André | last post by:
Hi, I put that question already, but it's still not very clear to me, so ... Assume following option in web.config= debug="false" but in one aspx page (test.aspx) <%@ debug="true" ..%>
4
by: Jonathan Wood | last post by:
Okay, I spent about 3 hours getting the GridView control to do what I needed. Basically, I set the control's AutoGenerateColumns to False and then defined a single template column (which I will...
9
by: Jamey Bon | last post by:
As a newbie to C#, I am not sure what I can do about this. I would like to do something like an Enumeration to use "constants" like Yes to indicate true and No for false. But since there seems to...
1
by: mato81 | last post by:
Hi all! I am a newbie to WSDL. I have a questions which has been driving me crazy... If I would have a WSDL with a types element somewhat like below, what is the point of the third last row...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...

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.