473,763 Members | 7,541 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Programatically Change Datagrid column type?

VS.NET 2003, C#, Windows Server 2003. I have a datagrid and I want the
last column to be either an EditCommandColu mn or a template column,
depending on a value I have. The value changes for each row. So some
rows will have an EditCommandColu mn, others just a text message in the
last column. Is this possible? I am already using the ItemDataBound
method to perform some function on each row, but I can't seem to
change the datagrid's column type programatically .

I tried some inline C#:

<%if(myBooValue ){%>
<asp:TemplateCo lumn...
<%} else {%>
<asp:EditComman dColumn...
<%{%>

But I received a runtime error: cannot use control block in that
context. Even if that worked, I'm looking for a way to do it cleanly
in the code-behind.

Another idea I had was to define both columns in the aspx datagrid,
then show-hide them in the code-behind depending on my value for that
row. But I can't figure out how to programatically ID the columns to
show or hide them.

Thanks,
Dan
Nov 18 '05 #1
0 1452

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

Similar topics

3
4838
by: Gil | last post by:
Hello, I use VB.NET and have a series of linkbuttons that are inside individual <td>s. Like this: <td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td> I would like the background of the td to be different for the currently selected linkbutton than for the other linkbuttons:
0
1672
by: CoreyMas | last post by:
Hello Everyone, I have been successful in creating a template column programatically using the examples provided in VS 2003. However I have not been able to programatically set the width of a template column programatically Here is the code that I have used so far
1
2121
by: Junkguy | last post by:
Hi all, I need some advice on how to sort the contents of a datagrid from code. The issue I have is a client that wants the datagrid to show its rows in "entry" order (i.e. the order in which rows appear in the database) after performing a new search to find some rows. This is actually how a datagrid will initially show its rows, but after the user clicks a column header, the datagrid will forever after show rows sorted according to...
1
3434
by: John E. | last post by:
I have a datagrid with one column that is boolean (it is a checkbox column). So that myDataTable.Column..DataType.UnderlyingSystemType == System.Boolean. For printing purposes, I would like to change this from a boolean to a string, so that I may manipulate the output to read "X" instead of true, and "" for false. If I attempt to change the DataColumn type currently, I get an error stating that I cannot change the type of a column when...
6
3248
by: Robert Schuldenfrei | last post by:
Dear NG, After being away from C# programming for a spell, I am trying my hand at what should be a simple task. I have been hitting my head against the wall this morning. I have a simple order entry application. The code below gets line items from a SQL Server database and returns them to a datagrid by way of a DataTable called lineTable. As long as I am just displaying columns in the SQL database everything works well. I now want...
0
1515
by: Dan Hartshorn | last post by:
VS.NET 2003, C#, Windows Server 2003. I have a datagrid and I want the last column to be either an EditCommandColumn or a template column, depending on a value I have. The value changes for each row. So some rows will have an EditCommandColumn, others just a text message in the last column. Is this possible? I am already using the ItemDataBound method to perform some function on each row, but I can't seem to change the datagrid's column...
0
954
by: spammy | last post by:
hi all, is there any way i can programatically determine the following fields in a datagrid column built using the property builder? i want to display in the grid a different table depending on the type passed in the querystring, but the <DataNavigateUrlField> and <childtype> will change depending on the table selected (as would the header name etc, but im assuming these will be able to set in the same way): <asp:HyperLinkColumn...
1
1581
by: mg | last post by:
I create a datagrid using the Web Forms Toolbo The dataadapter,dataset and databind() code runs in a button eventhandler The headertext is currently determined by the column names of my SQL select statement there How can I change the headertext programatically in the codebehind? ... I don't want to change the preexisting code if at all possible.
1
2181
by: DotNetJunkies User | last post by:
Hi, I was wondering if it is possible to load datagrid into datalist programatically using ITemplate interface with the following structure and place intp placeholder control. PlaceHolder - DataList - DataGrid (DataList Item) I have hierarchical data that I want to display using webcontrols whilst calculating minimum cost for each courier with Compute() method in DataGrid.
2
7499
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView nodes. The TreeView populates dynamically as there are a significant number of nodes. The DataGrid displays both the items and the nodes from the TreeView. Using the explorer analogy this means the TreeView shows folders, and the DataGrid folders...
0
9563
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
9997
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9937
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
8821
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
7366
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
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2793
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.