473,698 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

datagrid column exists

Hi,

I am creating datagrid bound column dynamically and need to check if a
datagrid column already exists?Is there a way to check this?

thanks
gane
Jun 5 '06 #1
4 2912
Is datagrid's Columns collection good for you? Note, that autogenerated
columns don't get there.

Eliyahu

"gane" <ga**@sdff.co m> wrote in message
news:Ow******** ******@TK2MSFTN GP05.phx.gbl...
Hi,

I am creating datagrid bound column dynamically and need to check if a
datagrid column already exists?Is there a way to check this?

thanks
gane

Jun 6 '06 #2
Hi,

Can you show me with a sample code?
I have something like this, i need to check if the column exists before i
add to the grid. how can i do with the collections.
foreach(DataCol umn c in dsinfo.Tables[0].Columns)

{

dgresults.Colum ns.Add(CreateBo undColumn(c));

}

Thanks

"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:e6******** *****@TK2MSFTNG P02.phx.gbl...
Is datagrid's Columns collection good for you? Note, that autogenerated
columns don't get there.

Eliyahu

"gane" <ga**@sdff.co m> wrote in message
news:Ow******** ******@TK2MSFTN GP05.phx.gbl...
Hi,

I am creating datagrid bound column dynamically and need to check if a
datagrid column already exists?Is there a way to check this?

thanks
gane


Jun 6 '06 #3
gane wrote:
Hi,

I am creating datagrid bound column dynamically and need to check if a
datagrid column already exists?Is there a way to check this?

Dynamically created columns do not persist between page loads so I'm not
sure why you need to check.You should only dynamically create and add
columns to a datagrid in the Page_Init event. From online help:

The DataGrid control does not store the contents of its Columns
collection into the view state. To add or remove a column dynamically,
you must programmaticall y add or remove the column everytime the page is
refreshed. Provide a Page_Init function that adds or removes the column
before the DataGrid control's state is reload and the control is
rebuilt. Otherwise, the changes to the Columns collection are not
reflected in the DataGrid control when it is displayed.
Note Although you can programmaticall y add columns to or remove
columns from the Columns collection of the DataGrid control, it is
easier to list the columns statically and then use the Visible property
to display or hide each column.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Jun 6 '06 #4
I am using sort functionality on the datagrid, which is not firing if i dont
have the datagrid binded in pageload.
so i need to rebind twice in pageload and onsortcommand, which creates the
dynamic bound columns twice.
But now i clearing the grid, instead of finding a way to check for existing
columns. Now it works.

Thanks
Gane
"Bob Barrows [MVP]" <re******@NOyah oo.SPAMcom> wrote in message
news:uQ******** ******@TK2MSFTN GP04.phx.gbl...
gane wrote:
Hi,

I am creating datagrid bound column dynamically and need to check if a
datagrid column already exists?Is there a way to check this?

Dynamically created columns do not persist between page loads so I'm not
sure why you need to check.You should only dynamically create and add
columns to a datagrid in the Page_Init event. From online help:

The DataGrid control does not store the contents of its Columns
collection into the view state. To add or remove a column dynamically,
you must programmaticall y add or remove the column everytime the page is
refreshed. Provide a Page_Init function that adds or removes the column
before the DataGrid control's state is reload and the control is
rebuilt. Otherwise, the changes to the Columns collection are not
reflected in the DataGrid control when it is displayed.
Note Although you can programmaticall y add columns to or remove
columns from the Columns collection of the DataGrid control, it is
easier to list the columns statically and then use the Visible property
to display or hide each column.

--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

Jun 6 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
318
by: amber | last post by:
Hello, I have a datagrid with about 5 columns. It's datasource is a dataset that also contains a 'comments' field, but I'm not displaying it, as it would take up too much space. What I would like to have, is a small 'button' in each row, that displays if a comment exists for that record, but doesn't if there is no comment. If a comment exists, the user can click the 'button' to open the comments in a small form. Is this possible? Thanks...
1
2462
by: Alpha Zero | last post by:
Hi! I have a datagrid containing single column. If user adds a new word, I want to check if this word does not contain any character except A-Z and this word doesn't exists in previous rows . If it exists, then user should be informed and this word should not be added to datagrid. How should I go about it?
1
1284
by: Newbie | last post by:
Hello! I need help in making my datagrid sortable by clicking a column header. In the datagrid's property builder, Allow Sorting is checked. I am using a Bound column and it's Sort Expression is set to the same value as the Data Field value. But I dont know how to implement: private void dgResults_SortCommand(object source, System.Web.UI.WebControls.DataGridSortCommandEventArgs e)
2
2351
by: Raj | last post by:
Hi, When we are sorting the DataGrid Boolean column the grid is becoming redcross. I have my own PPMIPDataGridBoolColumn class inherited from System.Windows.Forms.DataGridBoolColumn. In this inherited class I have one DataGridValueChangedEventHandler event handler. I am overriding Edit() to know the current state of the cell. I am overriding Paint() to know the if the user has been editing the cell. I am also overriding the Commit() to
5
12235
by: John Richardson | last post by:
I've been bothered for some time about my DataGrid not populating my rows very quickly. I have about 10K rows loading into the grid. I create a datatable dt with 2 columns, an ID and a display. The ID is a member of the keys array. I then create a DataView dv over the table, and sort it by Display and ID column (in case of duplicate Display). I then set my DataGrid.DataSource = dv; I then load the datatable with my rows, and this is...
2
1376
by: simon | last post by:
I have template column in dataGrid and visible=false. <asp:TemplateColumn visible=false> <ItemTemplate><asp:CheckBox Runat=server ID=chkExists Checked='<%# Container.DataItem( "obstaja" ) % >'></asp:CheckBox> </ItemTemplate> </asp:TemplateColumn> When user clicks link button in dataGrid I check the chkExists value: Private Sub dgdAdvert_ItemCommand(ByVal source As Object, ByVal e As...
2
6404
by: CSL | last post by:
I am using the DataGrid in a Windows Application, how can I adjust the widths of each column individually.
0
974
by: Subhash | last post by:
Hello All I have one problem related to Datagrid. I have one datagrid which has a column. The data which is supposed to appear in this column contains mulitple lines. But I want them all to fit in a fixed width say 20%. But when I bind the grid the column which contains long data grows according to the data it contains. I want to stop it and have a fixed width column whose width would never exceed from the specified value.
2
1774
by: cj | last post by:
I was looking over some of my 2003 code today (see below) that loads a foxpro table via oledb connection. I used a sub "autosizecolumns" I found on the web but I never quite understood why they said the style name had to be the same as the table name. Perhaps the are refering to ts1.mappingname must be the same as the table name (datagrid1.datamember) because I've read that that is how the datagrid associates a style with what it's...
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8905
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7743
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.