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

Two way databinding using variable names

Is it possible to use a publicly scoped string vaiable as an argument
to the bind method?

A normal bind method works like this:

<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CustID")
%>'></asp:TextBox>

I get an error when I try this:

Public strCustIDFieldName as String="CustID"

<asp:TextBox ID="Text1" runat="server" Text='<%#
Bind(strCustIDFieldName) %>'></asp:TextBox>

The error is:

"A call to Bind was not well formatted"

The documentation says I can use any publicly scoped code,and it works
fine with the eval function.

Are literals the only thing allowed?

Apr 29 '06 #1
1 1281
You can do this:

<script runat="server">
string GetPropName()
{
return "SomePropName";
}
</script>

<asp:Repeater runat="server" ID="_rep">
<ItemTemplate>
<%# Eval(GetPropName()) %><br />
</ItemTemplate>
</asp:Repeater>

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

Is it possible to use a publicly scoped string vaiable as an argument
to the bind method?

A normal bind method works like this:

<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CustID")
%>'></asp:TextBox>

I get an error when I try this:

Public strCustIDFieldName as String="CustID"

<asp:TextBox ID="Text1" runat="server" Text='<%#
Bind(strCustIDFieldName) %>'></asp:TextBox>
The error is:

"A call to Bind was not well formatted"

The documentation says I can use any publicly scoped code,and it works
fine with the eval function.

Are literals the only thing allowed?

May 1 '06 #2

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

Similar topics

2
by: Colin Robinson | last post by:
Help please I have an example class called Person with 2 public properties Firstname and Lastname, I cant create a textbox on an asp.net form bound to the Person.Firstname property Can...
3
by: Kevin Swanson | last post by:
I'm writing what should be a very simple app against an Oracle database. The app has a number of user controls, any one of which is loaded into a main display page using the loadControl method,...
4
by: Nathan Sokalski | last post by:
I have two databinding expressions (the first & last names from a DB) that I want to assign to the text property of a Label so that the result is LASTNAME,FIRSTNAME. At the moment, I have the...
6
by: Nathan Sokalski | last post by:
I am using a DataSet as the DataSource of a DataList in my code. The SQL used to get the data from the database begins with: SELECT...
3
by: Tom McLaughlin | last post by:
I am new to vb.net and I am running into problems understanding DataBinding and its concept. The only examples I find are always talk about Web design, I only want to use this data on my...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
1
by: Mundo | last post by:
Hi I'm pulling my hair out with a problem caused when DataBinding a DataSet to a web control. I first tried using a GridView but when that failed, I tried a Repeater. I'm getting the classic...
1
by: Richa Bhargava | last post by:
how we can do dynamic databinding into datagrid in webform. we are getting the data from sql server 2000 .On the datagrid , only the field names should come on the frist row using one db table and...
2
by: Nathan Sokalski | last post by:
I have a Repeater that uses a DataSource that has multiple fields. When the values of these fields is displayed in the Repeater, there are fields that are used in combination with other fields as...
0
by: nelsonbrodyk | last post by:
Hey All, I have been able to set up a databinding to a property with the following code: <TextBox x:Name="txtTextBox" Text="{Binding Path=NameFirst, Mode=TwoWay,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.