473,703 Members | 4,416 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("ArrF ield")
%>
<td><%# DataBinder.Eval (Container.Data Item, i.ToString() %>
</td>
<%Next %>
Nov 19 '05 #1
3 2047
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("ArrF ield")
%>
<td><%# DataBinder.Eval (Container.Data Item, 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.Data Item, 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****@NOSPAMd evelop.com> wrote in message
news:76******** **************@ msnews.microsof t.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("ArrF ield")
%>
<td><%# DataBinder.Eval (Container.Data Item, 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(c ell);
cell = new TableCell();
cell.Text = yourData.Data;
row.Cells.Add(c ell);
YourTableInTheA SPX.Rows.Add(ro w);
}
}
}

-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.Data Item, 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****@NOSPAMd evelop.com> wrote in message
news:76******** **************@ msnews.microsof t.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("ArrF ield")
%>
<td><%# DataBinder.Eval (Container.Data Item, 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
281
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 fData as new frmData()
0
2345
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 visual representation of data. Two types of data binding are available for Windows Forms: Simple Data Binding and Complex Data Binding. Simple data binding allows you to bind one data element to a control. In many situations you want to display...
16
3029
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 example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
1
3935
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 lots of small 'objects' that need to be loaded into memory at runtime, in order to garantee small access time to each 'object'. Each of these 'objects' collection should be able to easily bind to a DataGridView, AND to provide *filtering* and...
1
2597
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 all? Here's an example: I want to do data binding on some of the properties of a TreeNode (namely its Name). Unfortunately, TreeNode does not derive from Control, so it doesn't have the "stock" data binding stuff. I'd like to create a new...
0
1718
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 sources to controls such as TextBox, ListBox, etc. I am clear on the concept of data flowing from data sources into web forms controls What I am not clear about is how to make the data flow the other way. When I am ready to save the changes or add a...
10
1914
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 to create my front end application. Building the data access forms using manual coding just seems like a lot of work.... Any guidance would be appreciated Fares
2
4911
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 TextBoxes) works fine the first time round. I can see, edit and update the details from my form, then close the form. I then like to select and refill the datatable with a different record (new
19
2223
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 applications without writing a single line of code!!!'. Personally, and I know I wasn't alone in this, I was always suspicious of this claim, because one invariably ended up writing huge amounts of code attempting to get the automagical thing to do...
14
14650
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 so I get the ObjectDataSource. No problem ..... ObjectDataSource src = .... //is ok i have it
0
8763
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
8676
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
9266
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9127
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...
0
8972
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5926
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4692
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3128
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
3
2073
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.