473,700 Members | 2,649 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Datalist control is bound by an element of the array ???

Hi all,

Data displayed on the datalist control is bound by the column name of the
dataset like this :

<%# DataBinder.Eval (Container.Data Item, "title")%>

Could I use an element of the array (i.e. index=0) which has the name
"title" in place of it ? For example:

<%# DataBinder.Eval (Container.Data Item, Array(0)) %>

Is there anything wrong with the syntax ? Please give me your advise.

Thanks in advance.

Nov 19 '05 #1
4 2210
Hi bienwell:

The DataItem will be an individual array element, so the syntax you
have here won't work, but ...

You can use code other than DataBinder.Eval in the expressions. See:
http://odetocode.com/Articles/278.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 6 May 2005 11:11:14 -0400, "bienwell" <bi******@hotma il.com>
wrote:
Hi all,

Data displayed on the datalist control is bound by the column name of the
dataset like this :

<%# DataBinder.Eval (Container.Data Item, "title")%>

Could I use an element of the array (i.e. index=0) which has the name
"title" in place of it ? For example:

<%# DataBinder.Eval (Container.Data Item, Array(0)) %>

Is there anything wrong with the syntax ? Please give me your advise.

Thanks in advance.


Nov 19 '05 #2
Scott,

After reading the document from the http://odetocode.com/Articles/278.aspx
link, I feel it does not like what I want to express. This document
mentionned about multiple values that we can load into the array "HexValue"
and we can bind data for this array. My question is different : I stored
the column names from the SQL statement into the array "ArrField" : For
example : "select Year, Port, SUM(Trucks) Trucks,
SUM(Empty_Truck _Containers) Empty_Truck_Con tainers, SUM(Trains) Trains FROM
table1 WHERE Year IN (1996,1997,1998 ) AND Port= 'AK:Alcan' GROUP BY Year,
Port ORDER BY Port, Year ". With this query, I stored columns "Trucks",
"Empty_Truck_Co ntainers", "Trains" into the array "ArrFields" and refer
them later in data binding. The field names in this array may change depends
on the selection from users. Like this, each column has multiple values in
each Year/Month. In the <itemtemplate >, I will use the For Loop to go
through these fields : The syntax like this :

<tr>
<% Dim i as integer
For i=0 to UBound(ViewStat e("ArrField") ) %>
<td>
<%# DataBinder.Eval (Container.Data Item, Array(i)) %>
</td>
<% Next %>
</tr>

I've got an error : "i is not declared "

I cannot specify the column names in data binding because they are
variables.
Do you have any ideas ? Thanks again.

=============== =============== =============== ===========
"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:gj******** *************** *********@4ax.c om...
Hi bienwell:

The DataItem will be an individual array element, so the syntax you
have here won't work, but ...

You can use code other than DataBinder.Eval in the expressions. See:
http://odetocode.com/Articles/278.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 6 May 2005 11:11:14 -0400, "bienwell" <bi******@hotma il.com>
wrote:
Hi all,

Data displayed on the datalist control is bound by the column name of the
dataset like this :

<%# DataBinder.Eval (Container.Data Item, "title")%>

Could I use an element of the array (i.e. index=0) which has the name
"title" in place of it ? For example:

<%# DataBinder.Eval (Container.Data Item, Array(0)) %>

Is there anything wrong with the syntax ? Please give me your advise.

Thanks in advance.

Nov 19 '05 #3

Hi bienwell:

I think I see what you are trying to achieve now.

What the article was trying to express was that you aren't restricted
to just using DataBinder in the data binding expressions. You could
invoke some other method of your class to spit out a string.

I'm not quite sure what you want to do in the code below. Did you want
a cell for each entry in the array? If so, it's probably easier to
nest another control inside the DataList cell - like put a Repeater,
DatList, DataGrid inside the cell.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 6 May 2005 12:53:56 -0400, "bienwell" <bi******@hotma il.com>
wrote:
Scott,

After reading the document from the http://odetocode.com/Articles/278.aspx
link, I feel it does not like what I want to express. This document
mentionned about multiple values that we can load into the array "HexValue"
and we can bind data for this array. My question is different : I stored
the column names from the SQL statement into the array "ArrField" : For
example : "select Year, Port, SUM(Trucks) Trucks,
SUM(Empty_Truc k_Containers) Empty_Truck_Con tainers, SUM(Trains) Trains FROM
table1 WHERE Year IN (1996,1997,1998 ) AND Port= 'AK:Alcan' GROUP BY Year,
Port ORDER BY Port, Year ". With this query, I stored columns "Trucks",
"Empty_Truck_C ontainers", "Trains" into the array "ArrFields" and refer
them later in data binding. The field names in this array may change depends
on the selection from users. Like this, each column has multiple values in
each Year/Month. In the <itemtemplate >, I will use the For Loop to go
through these fields : The syntax like this :

<tr>
<% Dim i as integer
For i=0 to UBound(ViewStat e("ArrField") ) %>
<td>
<%# DataBinder.Eval (Container.Data Item, Array(i)) %>
</td>
<% Next %>
</tr>

I've got an error : "i is not declared "

I cannot specify the column names in data binding because they are
variables.
Do you have any ideas ? Thanks again.

============== =============== =============== ============
"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:gj******* *************** **********@4ax. com...
Hi bienwell:

The DataItem will be an individual array element, so the syntax you
have here won't work, but ...

You can use code other than DataBinder.Eval in the expressions. See:
http://odetocode.com/Articles/278.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 6 May 2005 11:11:14 -0400, "bienwell" <bi******@hotma il.com>
wrote:
>Hi all,
>
>Data displayed on the datalist control is bound by the column name of the
>dataset like this :
>
><%# DataBinder.Eval (Container.Data Item, "title")%>
>
>Could I use an element of the array (i.e. index=0) which has the name
>"title" in place of it ? For example:
>
><%# DataBinder.Eval (Container.Data Item, Array(0)) %>
>
>Is there anything wrong with the syntax ? Please give me your advise.
>
>Thanks in advance.
>
>


Nov 19 '05 #4
Scott,

What I want to do is to use the array of field names for data binding
instead of specifying the field name:
For Example: Users might select field names "Trains", Trucks" in order to
know the Total of Trains and Trucks from the table. In my table, there are
the fieds : Trucks, Trains, Passengers, Pedestrians .... that have the value
number for Month, Year. I cannot specify the field names in data binding
like this:
<td>
<%# DataBinder.Eval (Container.Data Item, "Trains" %>
</td>
<td>
<%# DataBinder.Eval (Container.Data Item, "Trucks" %>
</td>

because the field names are variables and depend on the selection from users
in the first page. I collected the field names from the selection and saved
into the array
"ArrayField " and do the For Loop for databinding

<%# DataBinder.Eval (Container.Data Item, Array(i)) %>

The problem now is the syntax error. It does not know the field names from
the array and gave me an error of the index in the array "i is not declared
". If I replace <%# DataBinder.Eval (Container.Data Item, Array(i)) %> by
<%# DataBinder.Eval (Container.Data Item, Array(0)) or <%#
DataBinder.Eval (Container.Data Item, Array(1)) or <%#
DataBinder.Eval (Container.Data Item, Array(2)) ... then I didn't get the
error.

I hope you get my idea this time. Sorry for my English that is not good.
Please send me e-mail if you're not clear about it.

Thanks again.
=============== =============== =============== =====
"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:7v******** *************** *********@4ax.c om...

Hi bienwell:

I think I see what you are trying to achieve now.

What the article was trying to express was that you aren't restricted
to just using DataBinder in the data binding expressions. You could
invoke some other method of your class to spit out a string.

I'm not quite sure what you want to do in the code below. Did you want
a cell for each entry in the array? If so, it's probably easier to
nest another control inside the DataList cell - like put a Repeater,
DatList, DataGrid inside the cell.

HTH,

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 6 May 2005 12:53:56 -0400, "bienwell" <bi******@hotma il.com>
wrote:
Scott,

After reading the document from the http://odetocode.com/Articles/278.aspxlink, I feel it does not like what I want to express. This document
mentionned about multiple values that we can load into the array "HexValue"and we can bind data for this array. My question is different : I storedthe column names from the SQL statement into the array "ArrField" : For
example : "select Year, Port, SUM(Trucks) Trucks,
SUM(Empty_Truc k_Containers) Empty_Truck_Con tainers, SUM(Trains) Trains FROMtable1 WHERE Year IN (1996,1997,1998 ) AND Port= 'AK:Alcan' GROUP BY Year,
Port ORDER BY Port, Year ". With this query, I stored columns "Trucks",
"Empty_Truck_C ontainers", "Trains" into the array "ArrFields" and refer
them later in data binding. The field names in this array may change dependson the selection from users. Like this, each column has multiple values ineach Year/Month. In the <itemtemplate >, I will use the For Loop to go
through these fields : The syntax like this :

<tr>
<% Dim i as integer
For i=0 to UBound(ViewStat e("ArrField") ) %>
<td>
<%# DataBinder.Eval (Container.Data Item, Array(i)) %>
</td>
<% Next %>
</tr>

I've got an error : "i is not declared "

I cannot specify the column names in data binding because they are
variables.
Do you have any ideas ? Thanks again.

============== =============== =============== ============
"Scott Allen" <sc***@nospam.o detocode.com> wrote in message
news:gj******* *************** **********@4ax. com...
Hi bienwell:

The DataItem will be an individual array element, so the syntax you
have here won't work, but ...

You can use code other than DataBinder.Eval in the expressions. See:
http://odetocode.com/Articles/278.aspx

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Fri, 6 May 2005 11:11:14 -0400, "bienwell" <bi******@hotma il.com>
wrote:

>Hi all,
>
>Data displayed on the datalist control is bound by the column name of the >dataset like this :
>
><%# DataBinder.Eval (Container.Data Item, "title")%>
>
>Could I use an element of the array (i.e. index=0) which has the name
>"title" in place of it ? For example:
>
><%# DataBinder.Eval (Container.Data Item, Array(0)) %>
>
>Is there anything wrong with the syntax ? Please give me your advise. >
>Thanks in advance.
>
>

Nov 19 '05 #5

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

Similar topics

1
4567
by: Mike Malter | last post by:
I take it that the only way to add rows to a DataList control is through DataBind? If not, how do I manually add rows to a DataList control? I have searched everywhere and can't find an example anywhere other than through building a DataTable, and then doing a DataBind. Thanks. Mike
0
3107
by: Alex | last post by:
Interested in more .NET stuff visit www.dedicatedsolutions.co.uk The DataList is not as powerful as the DataGrid. It requires more work from you since it has no default data presentation format. However, the DataGrid begins to get very cumbersome as the number of columns of data you present increases. Anything more than half a dozen columns or so and you probably induce horizontal scrolling - a real no-no for me. If you put such a...
1
2671
by: Scott Schluer | last post by:
Hello, I've got myself a small problem and I'm hoping someone can help. I have a DataList called dlProducts (displays products from a database). Within the <ItemTemplate> container of the DataList, I have a PlaceHolder control called phVariations. During the ItemDataBound event for dlProducts, I dynamically create a few DropDownLists (again, from a database) and .Add the DropDownList to the PlaceHolder control. That all works just...
0
1173
by: Charlie | last post by:
Hi: I have a DataList that uses an HTML table to format items in its bound datasource. No server side control templates are used. When form posts back from a button click (separate from datalist), I get a reference to the data in button click event using "DataList.Items.Controls". This gives me a reference to a DataBoundLiteralControl object which has as it's Text property the HTML from DataList viewstate. Looking at it in the...
2
1454
by: Andrew | last post by:
Hi, How do I access the cells of a table that is located in a datalist control ? I have the datalist control and some asp controls in it up n it is working fine. My datalist is bound to a dataset. I want to put in an if-else statement that states that if an array element equals 1 (default 0), then the bgcolor of a particular cell is RED. Below I have given a sniplet of my code:
1
3707
by: studen771 | last post by:
Thanks in advance to anyone who can help :) I have my datalist bound to a normal, single dimension string array (with three elements) as its data source. In the scripting for the datagrid, I have it creating a table element in the <HeaderTemplateand creating a row in the <ItemTemplatesection. The <FooterTemplateonly has a closing </tabletag within it. The problem: The datagrid is repeating all of the elements in the array as rows in...
0
1459
by: HP | last post by:
Hi there I have a datalist control with some bound controls in its Item Template and a gridview bound to one of those fields (residing also in Item Template). I've found out that when I click Edit on the gridview (same happens when editing other gridview which is outside the datalist) all datalist bound fields (except the gridview) disappear, and they don't appear after submitting GV changes - they do only after changing value of some
6
2220
by: Victor | last post by:
Hi. all I have a customize web control. I have three simple properties and customized render class. then I add this control into my datalist like <asp:DataList ID="datalist" runat="server" RepeatColumns="3"> <ItemTemplate> <uc:mycontrol id="test" runat="server" /> </ItemTemplate> </asp:DataList> In the code-behind I have something like List<mycontrol lst = new List<mycontrol >;
3
2808
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I need to control the visibility of a textbox based on a dropdown selection in the datalist's edititem template. To do this, I registered a client script block function and attached a client side handler for the dropdownlist's onchange event in the...
0
8726
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
8645
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,...
0
9075
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
8973
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
7810
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
6561
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...
1
3089
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
2
2392
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2028
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.