473,471 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DataBind question

I have to bind a field whose name include parentheses to a label web control
in ASP.NET 2.0 . When I write code as following:
<%# Eval("[MyColumnName(kg)]"%>
a exception will be thrown at runtime: "MyColumnName(kg is not a DataColumn
or...". The field name is trimmed after ")".
Is anyone know how to reference to a field name with parentheses inside?
Dec 14 '05 #1
4 1257
I played with a couple variations, couldn't get it to work.

Change the datatable's column names. You can do this without changing the
underlying database. If you are using a typed dataset, this is cake.

If not, it can still be done easily via the TableMapping property of your
data adapter. This let's you map a column in your database into something
named different in your datatable.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"cobra300" <co******@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
I have to bind a field whose name include parentheses to a label web
control
in ASP.NET 2.0 . When I write code as following:
<%# Eval("[MyColumnName(kg)]"%>
a exception will be thrown at runtime: "MyColumnName(kg is not a
DataColumn
or...". The field name is trimmed after ")".
Is anyone know how to reference to a field name with parentheses inside?

Dec 14 '05 #2
This probably does not help you much, but

<ASP:TEMPLATECOLUMN ><ITEMTEMPLATE><%# container.dataitem("Something
(else)") %></ITEMTEMPLATE></ASP:TEMPLATECOLUMN>

seems to work just fine in my ASP.NET 1.1.4322 ( VB.NET ) project

Dec 14 '05 #3
No, it's the dataBinder.Eval() that's getting tripped up.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"addup" <ad*****@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
This probably does not help you much, but

<ASP:TEMPLATECOLUMN ><ITEMTEMPLATE><%# container.dataitem("Something
(else)") %></ITEMTEMPLATE></ASP:TEMPLATECOLUMN>

seems to work just fine in my ASP.NET 1.1.4322 ( VB.NET ) project

Dec 14 '05 #4
Thanks. I bound the label directly to a SqlDataSource control, so I can't
change the underlying DataTable's column name. I found another solution:
change the binding code to <%#
((DataRowView)Container.DataItem)["MyColumnName(kg)"] %>, it will work. I
think it may be a bug of Eval.

"Karl Seguin" wrote:
I played with a couple variations, couldn't get it to work.

Change the datatable's column names. You can do this without changing the
underlying database. If you are using a typed dataset, this is cake.

If not, it can still be done easily via the TableMapping property of your
data adapter. This let's you map a column in your database into something
named different in your datatable.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"cobra300" <co******@discussions.microsoft.com> wrote in message
news:53**********************************@microsof t.com...
I have to bind a field whose name include parentheses to a label web
control
in ASP.NET 2.0 . When I write code as following:
<%# Eval("[MyColumnName(kg)]"%>
a exception will be thrown at runtime: "MyColumnName(kg is not a
DataColumn
or...". The field name is trimmed after ")".
Is anyone know how to reference to a field name with parentheses inside?


Dec 16 '05 #5

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

Similar topics

3
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the...
2
by: Andrew | last post by:
Hey all, Have a strange one here, and being still fairly new to .NET isn't helping me understand it. I am having a problem where a DataReader doesn't return all the rows when I try to use a...
10
by: aualias | last post by:
This seems like such a lame question, but how do you bind to a CheckBox with ASP.NET? With Windows Forms there is a DataBindings collection. I do not see it with the web version of the control,...
0
by: Bryce Budd | last post by:
Hi, I have a webform which has several server controls attached. The entire form is data bound to custom objects. The collection objects are cached using the Cache object. In my use case, I...
11
by: Rourke Eleven | last post by:
I have looked and searched. What good is the databind property on Radiobuttons? How does one go about actually using it? What is a good resource on this? I understand that I can easily get/set...
1
by: Craig | last post by:
This is killing me, I've been trying to figure this out for 2 days. When I click on the linkbutton, it executes the GetData(int) method to set the DataSource. The FAILURE is when it tries to...
7
by: ThunderMusic | last post by:
Hi, This question probably went back a couple of times, but I didn't find anything about it on google, so I ask here... What is the best way to use the DataSource/DataBind pattern in a class? I...
0
by: ack95 | last post by:
Simply question How can I DataBind() a DataViewManager to a GridView in ASP.NET? Question in Detail We have a DataSet with relational DataTables (total of 5). We are generating emails with...
2
by: Steve Hershoff | last post by:
Hi everybody, I have a question about asp.net's labels and the DataBind method. I have a method in a code-behind page (this is VisualStudio 2003 btw) that (simplified) looks like this: ...
6
by: Jonathan Wood | last post by:
I have a databound dropdownlist control. Based on some other criteria, I need to specify the selected item in my pages Load event. The problem is that, in my load event, the control does not yet...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.