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

Data Binding Question

Hi, All,

Is it possible to access a variable inside of a data binding, without the
variable being out of scope?
(Note: On the DataBinder line, I get an error message that says "Name 'i' is
not declared". The data bind is for a DataList.)



Example:

<%
Dim i As String
For Each i In ViewState("ArrField")
%>
<td><%# DataBinder.Eval(Container.DataItem, i.ToString() %>
</td>
<%Next %>
Nov 19 '05 #1
3 2031
No, the <%%> syntax is put into a Render method, which is a seperate method
from the <%# %> DataBinding code snippet. What exactly are you trying to
do... this looks very ASP-sih. Maybe we can suggest a more ASP.NET appropriate
approach.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi, All,

Is it possible to access a variable inside of a data binding, without
the
variable being out of scope?
(Note: On the DataBinder line, I get an error message that says "Name
'i' is
not declared". The data bind is for a DataList.)
Example:

<%
Dim i As String
For Each i In ViewState("ArrField")
%>
<td><%# DataBinder.Eval(Container.DataItem, i.ToString() %>
</td>
<%Next %>


Nov 19 '05 #2
Brock,

I have several nested DataList controls, which are similar to the
Drilldown report that can be found in the Reports Starter Kit. The
difference is that in one of the DataList controls, I would like to
iterate through an array (some collection) to create table definitions
(<td>s) for the DataList. The size and content of the collection is
determined by the user's selections. With the collection I would like
to do two things.

1. Define the header template
2. Bind data to the DataList control inside the item template. The
items inside of the collection are columns in a DataSet. That's
explains (<%#
DataBinder.Eval(Container.DataItem, i.ToString() %>)

The DataGrid control may be more suitable but I would like to drilldown
one more time, as seen below. Note, I would be drilling down into a
DataGrid.
Sometimes it's hard to give up old habits.

bbernienb

Cars Trucks Buses
1990 DATA DATA DATA
1991 DATA DATA DATA
1992 DATA DATA DATA
1993 DATA DATA DATA
1994 DATA DATA DATA
1995 DATA DATA DATA


Cars Trucks Buses
1990 DATA DATA DATA
Jan DATA DATA DATA
Feb DATA DATA DATA
Mar DATA DATA DATA
Apr DATA DATA DATA
May DATA DATA DATA
Jun DATA DATA DATA
Jul DATA DATA DATA
Aug DATA DATA DATA
Sep DATA DATA DATA
Oct DATA DATA DATA
Nov DATA DATA DATA
Dec DATA DATA DATA
1991 DATA DATA DATA
1992 DATA DATA DATA
1993 DATA DATA DATA
1994 DATA DATA DATA
1995 DATA DATA DATA

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:76**********************@msnews.microsoft.com ...
No, the <%%> syntax is put into a Render method, which is a seperate method from the <%# %> DataBinding code snippet. What exactly are you trying to
do... this looks very ASP-sih. Maybe we can suggest a more ASP.NET appropriate approach.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi, All,

Is it possible to access a variable inside of a data binding, without
the
variable being out of scope?
(Note: On the DataBinder line, I get an error message that says "Name
'i' is
not declared". The data bind is for a DataList.)
Example:

<%
Dim i As String
For Each i In ViewState("ArrField")
%>
<td><%# DataBinder.Eval(Container.DataItem, i.ToString() %>
</td>
<%Next %>


Nov 19 '05 #3
So why don't you just do this all in codebehind and dynamically create a
Table, TableRow and TableCell objects? Pseudocode sample:

void Page_Load(...)
{
if (YourCondition)
{
yourData = GetYourData();
for (int i = 0; i < yourData.Length; i++)
{
TableRow row = new TableRow();
TableCell cell = new TableCell();
cell.Text = i.ToString();
row.Cells.Add(cell);
cell = new TableCell();
cell.Text = yourData.Data;
row.Cells.Add(cell);
YourTableInTheASPX.Rows.Add(row);
}
}
}

-Brock
DevelopMentor
http://staff.develop.com/ballen
Brock,

I have several nested DataList controls, which are similar to the
Drilldown report that can be found in the Reports Starter Kit. The
difference is that in one of the DataList controls, I would like to
iterate through an array (some collection) to create table definitions
(<td>s) for the DataList. The size and content of the collection is
determined by the user's selections. With the collection I would like
to do two things.

1. Define the header template
2. Bind data to the DataList control inside the item template. The
items inside of the collection are columns in a DataSet. That's
explains (<%#
DataBinder.Eval(Container.DataItem, i.ToString() %>)
The DataGrid control may be more suitable but I would like to
drilldown one more time, as seen below. Note, I would be drilling down
into a DataGrid.

Sometimes it's hard to give up old habits.

bbernienb

Cars Trucks Buses
1990 DATA DATA DATA
1991 DATA DATA DATA
1992 DATA DATA DATA
1993 DATA DATA DATA
1994 DATA DATA DATA
1995 DATA DATA DATA
Cars Trucks Buses
1990 DATA DATA DATA
Jan DATA DATA DATA
Feb DATA DATA DATA
Mar DATA DATA DATA
Apr DATA DATA DATA
May DATA DATA DATA
Jun DATA DATA DATA
Jul DATA DATA DATA
Aug DATA DATA DATA
Sep DATA DATA DATA
Oct DATA DATA DATA
Nov DATA DATA DATA
Dec DATA DATA DATA
1991 DATA DATA DATA
1992 DATA DATA DATA
1993 DATA DATA DATA
1994 DATA DATA DATA
1995 DATA DATA DATA
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:76**********************@msnews.microsoft.com ...
No, the <%%> syntax is put into a Render method, which is a seperate

method
from the <%# %> DataBinding code snippet. What exactly are you trying
to do... this looks very ASP-sih. Maybe we can suggest a more ASP.NET

appropriate
approach.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi, All,

Is it possible to access a variable inside of a data binding,
without
the
variable being out of scope?
(Note: On the DataBinder line, I get an error message that says
"Name
'i' is
not declared". The data bind is for a DataList.)
Example:
<%
Dim i As String
For Each i In ViewState("ArrField")
%>
<td><%# DataBinder.Eval(Container.DataItem, i.ToString() %>
</td>
<%Next %>


Nov 19 '05 #4

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

Similar topics

1
by: Marcin Floryan | last post by:
Hello! My question regards opening (and re-opening) Form and the Load event. I have a main form (frmMain) and I also have a data form (frmData). In the main form I have created: Private...
0
by: Ann Morris | last post by:
INTRODUCTION One of the most powerful aspects of .NET and Windows Forms is data binding. Data binding is the process of associating user interface (UI) elements with a data source to generate a...
16
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For...
1
by: Patrick | last post by:
Hi all, New to .NET, I'm working on an Winforms client application using VS 2005 beta2. My needs considering data storage are the followings: (1) Small files (0 < length < 10 mb), containing...
1
by: matty.hall | last post by:
There's a lot of information out there about data-binding UI objects (i.e. derived from Control) to non-UI custom business objects. Is it possible to do the same without any UI being involved at...
0
by: popsovy | last post by:
Hi I have a question about whether Data Binding can facilitate the process of saving data in a web application I learned that you can data bind information from a number of different data...
10
by: Fares Eidi | last post by:
I am a VB6 intermediate programmer just starting out using VB.net and would like to ask what I'd be missing out on if I just use time saving techniques like data binding, data adapter wizards etc...
2
by: Matthias | last post by:
Hi Team this may be a newbie question. I have searched the discussions before posting: I'd like to re-use a form instance to edit record details. My data binding (a DataTable bound to...
19
by: Larry Lard | last post by:
In the old days (VB3 era), there was a thing called the Data Control, and you could use it to databind controls on forms to datasources, and so (as the marketing speak goes), 'create database...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
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: 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
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...
1
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...

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.