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

Binding data to a server control inside repeator control

Hi guys,

Iam using a repeator control in my page.In wich i have
dropdown list as the last column.I have a label in the first
column.Now i have binded a datable to the repeator in the page load
event.And assigned vale to the label in html as

<asp:Label ID="c_invAmt" Runat="server" cssclass="smcsAmountLabel">
<%# DataBinder.Eval(Container.DataItem,"InvoiceAmount" ) %>
</asp:Label>
Now i want to bind data to the dropdown list in the last column.I have
a function that returns a datatable.

I tried to bind the dropdown in html as follows

<asp:DropDownList ID="c_currencyList" Runat="server" Visible="False"
DataSource='<%=GetCurrencies()%>' DataTextField="XXX"
DataValueField="XXX">
</asp:DropDownList>

But it throws an error saying

The datasource property is set only by the run time.It cannot be
declared.

So i tried to bind the dropdown list in the itemdatabound event of the
repeator.But the data is not binded to the dropdown list.

How can i achieve that.Can any one help me out...........

Apr 6 '06 #1
3 1704
So bind it at runtime

"muthu" wrote:
Hi guys,

Iam using a repeator control in my page.In wich i have
dropdown list as the last column.I have a label in the first
column.Now i have binded a datable to the repeator in the page load
event.And assigned vale to the label in html as

<asp:Label ID="c_invAmt" Runat="server" cssclass="smcsAmountLabel">
<%# DataBinder.Eval(Container.DataItem,"InvoiceAmount" ) %>
</asp:Label>
Now i want to bind data to the dropdown list in the last column.I have
a function that returns a datatable.

I tried to bind the dropdown in html as follows

<asp:DropDownList ID="c_currencyList" Runat="server" Visible="False"
DataSource='<%=GetCurrencies()%>' DataTextField="XXX"
DataValueField="XXX">
</asp:DropDownList>

But it throws an error saying

The datasource property is set only by the run time.It cannot be
declared.

So i tried to bind the dropdown list in the itemdatabound event of the
repeator.But the data is not binded to the dropdown list.

How can i achieve that.Can any one help me out...........

Apr 6 '06 #2
What do you mean to say.....

Apr 6 '06 #3
The error says you can't bind the data like you are doing, i.e.
declaratively, you can only do it at runtime. So do it at runtime instead.

E.G. Don't do this:

DataSource='<%=GetCurrencies()%>'

Put something like this in you pageload event

if (!IsPostBack)
{
c_currencyList.DataSource = SomeDataSourceObject;
c_currencyList.DataBind();
}

"muthu" wrote:
What do you mean to say.....

Apr 6 '06 #4

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

Similar topics

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...
2
by: Steve Lloyd | last post by:
Hi there, I have a set of products each of which has attributes (color size etc), is it possible to use a data list or repeator to display all the items and provide combo box with a unique set...
1
by: Dot net work | last post by:
Hello. I have an interesting data binding scenario: I have a repeater control. It repeats a typical custom web user control. I also have a collection object, and each collection element...
3
by: bbernieb | last post by:
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...
9
by: Timm | last post by:
I have an ASP.NET 2.0 page with two DropDownLists. I am using declarative data binding wherever possible and trying to minimize the use of code. The list of values in DropDownList DDL2 should be...
1
by: muthu | last post by:
Hi freinds, Iam using repeator control in my application.The code behind is vb.net. I have n number of rows and 5 columns in the repeator control.In the ItemDataBound event of the repeator...
0
by: muthu | last post by:
Hi guys, Iam using a repeator control in my page.In wich i have dropdown list as the last column.I have a label in the first column.Now i have binded a datable to the repeator in the page load...
3
by: Simon Tamman | last post by:
I've come across an interesting bug. I have workarounds but i'd like to know the root of the problem. I've stripped it down into a short file and hope someone might have an idea about what's going...
0
by: =?Utf-8?B?TWlrZSBNaWxpYW4=?= | last post by:
I have a dropdownlist control in a formview and I am trying to enable 2 way databinding. Only, the option is not available. I look at the "Edit Databinding" option of another DDL control in the...
2
by: =?Utf-8?B?Q29sb3JzdG9uZQ==?= | last post by:
Hi, I have a TabContainer inside a data bound FormView (to logically group the form fields into different tabs). The display part of the data binding works fine, but the Update doesn't. ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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,...
0
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...
0
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...

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.