473,404 Members | 2,137 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,404 software developers and data experts.

using DataBinder.Eval programatically

Hi,

I currently have the following HTML code for a button:

<asp:Button id=SelectButton runat="server" Text='<%# DataBinder.Eval
(Container.DataItem, "PageName") %>' CommandName='<%# DataBinder.Eval
(Container.DataItem, "PageName") %>'> </asp:Button>

The text for the button is evaluated at runtime. I am now trying to do
the same but for a button that I create programatically:

Button btn = new Button();
btn.ID = "SelectButton";
btn.Text = "<%# DataBinder.Eval(Container.DataItem, \"PageName\") %>";
btn.CommandName = "<%# DataBinder.Eval(Container.DataItem, \"PageName\")
%>";
container.Controls.Add(btn);

However, the text is literally the string.

Thanks,

Jeronimo
Nov 17 '05 #1
1 3067
Hi Jeronimo,

As I understand, you want to know "How to use DataBinder.Eval
programatically in the C# code".

Based on my research and experience, the following Knowledge Base article
is useful to you. Please refer to it carefully.

HOW TO: Use the ItemDataBound Event of Web Forms List Controls in Visual C#
.NET
http://support.microsoft.com/default...b;en-us;317582
"...
protected void FormatRepeaterRow(Object sender, RepeaterItemEventArgs e)
{
if( (e.Item.ItemType == ListItemType.Item) || ( e.Item.ItemType ==
ListItemType.AlternatingItem))
{
DbDataRecord dbr = (DbDataRecord)e.Item.DataItem;
if( Convert.ToString(DataBinder.Eval(dbr, "Country")) == "USA" )
((Label)e.Item.FindControl("lblContactName")).Fore Color =
System.Drawing.Color.Red;
}
}
..."

Does it answer your question? If I have misunderstood your concern, please
feel free to let me know.

Best regards,

Jacob Yang
Microsoft Online Partner Support
Get Secure! ¨C www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 17 '05 #2

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

Similar topics

0
by: Michelle Keys | last post by:
Subject: DataBinder.Eval Error! Server Error in '/MSPOS' Application. ------------------------------------------------------------------------ -------- DataBinder.Eval:...
4
by: Bernie V | last post by:
Hi group, Is it possible to use a condition in a repeater control ? I 'd like to use a condition to create this <a href='<%#DataBinder.Eval(Container.DataItem,"nieuwsid")%>.aspx'> part of the...
2
by: dm_dal | last post by:
I have a control on my webform that I am binding to a dataset. The issue is, the field value in the dataset is encrypted and I am trying to decrypt it during the binding process: Example: ...
4
by: Søren Lund | last post by:
Hello, I am trying to bind a DataGrid with some data from a DataSet which contains fields in the form "group.fieldname". I am certain that my data source contains the field but I cannot get my...
7
by: Tarren | last post by:
Hi: I am pulling duration out of my DB and it returns duration in seconds. For the display i would like to show it in time format with colon So duration of 221 I want it to display 03:41 ...
3
by: Eric Newton | last post by:
Given databinding an array of System.Version types: Given that "SomeObject" type has a Version property: public class SomeObject { public Version Version { get; } public string Description {...
1
by: ratnakarp | last post by:
Hi, I have a search text box. The user enters the value in the text box and click on enter button. In code behind on button click i'm writing the code to get the values from the database and...
2
by: MrCrool | last post by:
Hi I need to be able to handle the following ASP programming in pure C# code: <asp:TemplateColumn HeaderText="Customer Information"> <ItemTemplate> <table border="0"> <tr> <td...
1
by: RobASPNewGuy | last post by:
Hi, I'm new to this forum and hope I can get some help. I would like to make life easier by combining a appSetting (global variable set in the web.config file) and DataBinder.Eval to create a...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.