473,320 Members | 1,979 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.

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 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 type programatically.

I tried some inline C#:

<%if(myBooValue){%>
<asp:TemplateColumn...
<%} else {%>
<asp:EditCommandColumn...
<%{%>

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 1426

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

Similar topics

3
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...
0
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...
1
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...
1
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...
6
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...
0
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...
0
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...
1
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...
1
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 -...
2
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
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...
0
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: 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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.