473,246 Members | 1,845 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,246 software developers and data experts.

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.DataItem, "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.DataItem, Array(0)) %>

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

Thanks in advance.

Nov 19 '05 #1
4 2183
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******@hotmail.com>
wrote:
Hi all,

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

<%# DataBinder.Eval(Container.DataItem, "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.DataItem, 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_Containers, 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_Containers", "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(ViewState("ArrField")) %>
<td>
<%# DataBinder.Eval(Container.DataItem, 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.odetocode.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******@hotmail.com>
wrote:
Hi all,

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

<%# DataBinder.Eval(Container.DataItem, "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.DataItem, 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******@hotmail.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_Truck_Containers) Empty_Truck_Containers, 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_Containers", "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(ViewState("ArrField")) %>
<td>
<%# DataBinder.Eval(Container.DataItem, 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.odetocode.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******@hotmail.com>
wrote:
>Hi all,
>
>Data displayed on the datalist control is bound by the column name of the
>dataset like this :
>
><%# DataBinder.Eval(Container.DataItem, "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.DataItem, 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.DataItem, "Trains" %>
</td>
<td>
<%# DataBinder.Eval(Container.DataItem, "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.DataItem, 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.DataItem, Array(i)) %> by
<%# DataBinder.Eval(Container.DataItem, Array(0)) or <%#
DataBinder.Eval(Container.DataItem, Array(1)) or <%#
DataBinder.Eval(Container.DataItem, 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.odetocode.com> wrote in message
news:7v********************************@4ax.com...

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******@hotmail.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_Truck_Containers) Empty_Truck_Containers, 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_Containers", "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(ViewState("ArrField")) %>
<td>
<%# DataBinder.Eval(Container.DataItem, 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.odetocode.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******@hotmail.com>
wrote:

>Hi all,
>
>Data displayed on the datalist control is bound by the column name of the >dataset like this :
>
><%# DataBinder.Eval(Container.DataItem, "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.DataItem, 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
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...
0
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....
1
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...
0
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...
2
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...
1
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...
0
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...
6
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"...
3
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...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
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: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: Aftab Ahmad | last post by:
So, I have written a code for a cmd called "Send WhatsApp Message" to open and send WhatsApp messaage. The code is given below. Dim IE As Object Set IE =...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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...

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.