473,659 Members | 2,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Use DataBinder.Eval inside of plain HTML tags with HTMLGenericCont rol?

I want to generate an HTML tag that will look like:

<a href="Equipment ServiceCreate.a spx?serial=X01" >Create New Service For X01</a>

or on a different instance where the user would be viewing "X05" it would looke like:

<a href="Equipment ServiceCreate.a spx?serial=X05" >Create New Service For X05</a>

I'm trynig to figure out how to do that using HtmlGenericCont rol in C# code behind.

Can DataBinder.Eval work inside of plain HTML tags?

I'm trying to do something like this:

<a id="CreateServi ceLink" runat="server"
href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
DataBinder.Eval (Container, "DataItem.owner _serial_num")
%>'x">Create New Service For</a>

But what is unclear to me is what I'd bind to the CreateServiceLi nk. A single DataRow?

But one can not do:

DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
CreateServiceLi nk.DataSource = SingleRow;

The HTMLGenericCont rol does not have DataSource as a property.

So can one not do this sort of thing with plain HTML?
Nov 19 '05 #1
8 2945
What is the origin of the instances you are refering to? Do they represent
rows in a table?

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:eB******** ******@TK2MSFTN GP14.phx.gbl...
I want to generate an HTML tag that will look like:

<a href="Equipment ServiceCreate.a spx?serial=X01" >Create New Service For X01</a>
or on a different instance where the user would be viewing "X05" it would looke like:
<a href="Equipment ServiceCreate.a spx?serial=X05" >Create New Service For X05</a>
I'm trynig to figure out how to do that using HtmlGenericCont rol in C# code behind.
Can DataBinder.Eval work inside of plain HTML tags?

I'm trying to do something like this:

<a id="CreateServi ceLink" runat="server"
href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
DataBinder.Eval (Container, "DataItem.owner _serial_num")
%>'x">Create New Service For</a>

But what is unclear to me is what I'd bind to the CreateServiceLi nk. A single DataRow?
But one can not do:

DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
CreateServiceLi nk.DataSource = SingleRow;

The HTMLGenericCont rol does not have DataSource as a property.

So can one not do this sort of thing with plain HTML?

Nov 19 '05 #2
Eliyahu Goldin wrote:
What is the origin of the instances you are refering to? Do they represent
rows in a table?
Yes.

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:eB******** ******@TK2MSFTN GP14.phx.gbl...
I want to generate an HTML tag that will look like:

<a href="Equipment ServiceCreate.a spx?serial=X01" >Create New Service For


X01</a>
or on a different instance where the user would be viewing "X05" it would


looke like:
<a href="Equipment ServiceCreate.a spx?serial=X05" >Create New Service For


X05</a>
I'm trynig to figure out how to do that using HtmlGenericCont rol in C#


code behind.
Can DataBinder.Eval work inside of plain HTML tags?

I'm trying to do something like this:

<a id="CreateServi ceLink" runat="server"
href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
DataBinder.Ev al(Container, "DataItem.owner _serial_num")
%>'x">Create New Service For</a>

But what is unclear to me is what I'd bind to the CreateServiceLi nk. A


single DataRow?
But one can not do:

DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
CreateServiceLi nk.DataSource = SingleRow;

The HTMLGenericCont rol does not have DataSource as a property.

So can one not do this sort of thing with plain HTML?


Nov 19 '05 #3
Then you should use a Repeater/DataList/DataGrid control, set its DataSource
and DataMember properties to the table where the instancs are, put the link
into the ItemTemplate and databind.

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:On******** *****@TK2MSFTNG P11.phx.gbl...
Eliyahu Goldin wrote:
What is the origin of the instances you are refering to? Do they represent rows in a table?


Yes.

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:eB******** ******@TK2MSFTN GP14.phx.gbl...
I want to generate an HTML tag that will look like:

<a href="Equipment ServiceCreate.a spx?serial=X01" >Create New Service For


X01</a>
or on a different instance where the user would be viewing "X05" it
would
looke like:
<a href="Equipment ServiceCreate.a spx?serial=X05" >Create New Service For


X05</a>
I'm trynig to figure out how to do that using HtmlGenericCont rol in C#


code behind.
Can DataBinder.Eval work inside of plain HTML tags?

I'm trying to do something like this:

<a id="CreateServi ceLink" runat="server"
href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
DataBinder.Ev al(Container, "DataItem.owner _serial_num")
%>'x">Create New Service For</a>

But what is unclear to me is what I'd bind to the CreateServiceLi nk. A


single DataRow?
But one can not do:

DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
CreateServiceLi nk.DataSource = SingleRow;

The HTMLGenericCont rol does not have DataSource as a property.

So can one not do this sort of thing with plain HTML?


Nov 19 '05 #4
I believe you can add the runat="server" to any html tag, and then it can be
cast to htmlgeneric control, or one of the more specific types. So, at that
point you would be able to add the databinder code as it would be processed
server side.

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:On******** *****@TK2MSFTNG P11.phx.gbl...
Eliyahu Goldin wrote:
What is the origin of the instances you are refering to? Do they
represent
rows in a table?


Yes.

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:eB******** ******@TK2MSFTN GP14.phx.gbl...
I want to generate an HTML tag that will look like:

<a href="Equipment ServiceCreate.a spx?serial=X01" >Create New Service For


X01</a>
or on a different instance where the user would be viewing "X05" it would


looke like:
<a href="Equipment ServiceCreate.a spx?serial=X05" >Create New Service For


X05</a>
I'm trynig to figure out how to do that using HtmlGenericCont rol in C#


code behind.
Can DataBinder.Eval work inside of plain HTML tags?

I'm trying to do something like this:

<a id="CreateServi ceLink" runat="server"
href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
DataBinder.E val(Container, "DataItem.owner _serial_num")
%>'x">Create New Service For</a>

But what is unclear to me is what I'd bind to the CreateServiceLi nk. A


single DataRow?
But one can not do:

DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
CreateServiceLi nk.DataSource = SingleRow;

The HTMLGenericCont rol does not have DataSource as a property.

So can one not do this sort of thing with plain HTML?



Nov 19 '05 #5
Eliyahu Goldin wrote:
Then you should use a Repeater/DataList/DataGrid control, set its DataSource
and DataMember properties to the table where the instancs are, put the link
into the ItemTemplate and databind.
1) I know the query returns only one row.

2) I do not want to use DataGrid or similar asp controls because I do NOT want a
table. I just want a single control at the bottom of the form that is a link to a
different form based on what the main record is for the current form.

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:On******** *****@TK2MSFTNG P11.phx.gbl...
Eliyahu Goldin wrote:
What is the origin of the instances you are refering to? Do they
represent
rows in a table?


Yes.

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:eB******** ******@TK2MSFTN GP14.phx.gbl...
I want to generate an HTML tag that will look like:

<a href="Equipment ServiceCreate.a spx?serial=X01" >Create New Service For

X01</a>

or on a different instance where the user would be viewing "X05" it
would
looke like:
<a href="Equipment ServiceCreate.a spx?serial=X05" >Create New Service For

X05</a>

I'm trynig to figure out how to do that using HtmlGenericCont rol in C#

code behind.
Can DataBinder.Eval work inside of plain HTML tags?

I'm trying to do something like this:

<a id="CreateServi ceLink" runat="server"
href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
DataBinder. Eval(Container, "DataItem.owner _serial_num")
%>'x">Create New Service For</a>

But what is unclear to me is what I'd bind to the CreateServiceLi nk. A

single DataRow?
But one can not do:

DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
CreateServiceLi nk.DataSource = SingleRow;

The HTMLGenericCont rol does not have DataSource as a property.

So can one not do this sort of thing with plain HTML?


Nov 19 '05 #6
Using Asp.net v1.1 btw.

I can't do this:

protected System.Web.UI.H tmlControls.Htm lGenericControl CreateServiceLi nk;

DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
CreateServiceLi nk.DataSource = SingleRow;

Why can't I do this? Because DataSource is not a member of HtmlGenericCont rol.

I also can not do:

CreateServiceLi nk.DataItem = SingleRow;

since, again, DataItem is not defined for HtmlGenericCont rol
Therefore DataItem does not get defined and I can't make this work.

<a id="CreateServi ceLink" runat="server"
href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
DataBinder.Eval (Container, "DataItem.owner _serial_num")
%>'x">Create New Service For</a>

Is there some way to define DataItem for an HtmlGenericCont rol so that
DataBinder.Eval can work?

Or is there some other mechanism to do what I want to do with an HtmlGenericCont rol
or some other HTML control?

Tim Cartwright wrote:
I believe you can add the runat="server" to any html tag, and then it can be
cast to htmlgeneric control, or one of the more specific types. So, at that
point you would be able to add the databinder code as it would be processed
server side.

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:On******** *****@TK2MSFTNG P11.phx.gbl...
Eliyahu Goldin wrote:
What is the origin of the instances you are refering to? Do they
represent
rows in a table?


Yes.

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:eB******** ******@TK2MSFTN GP14.phx.gbl...
I want to generate an HTML tag that will look like:

<a href="Equipment ServiceCreate.a spx?serial=X01" >Create New Service For

X01</a>

or on a different instance where the user would be viewing "X05" it would

looke like:
<a href="Equipment ServiceCreate.a spx?serial=X05" >Create New Service For

X05</a>

I'm trynig to figure out how to do that using HtmlGenericCont rol in C#

code behind.
Can DataBinder.Eval work inside of plain HTML tags?

I'm trying to do something like this:

<a id="CreateServi ceLink" runat="server"
href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
DataBinder. Eval(Container, "DataItem.owner _serial_num")
%>'x">Create New Service For</a>

But what is unclear to me is what I'd bind to the CreateServiceLi nk. A

single DataRow?
But one can not do:

DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
CreateServiceLi nk.DataSource = SingleRow;

The HTMLGenericCont rol does not have DataSource as a property.

So can one not do this sort of thing with plain HTML?

Nov 19 '05 #7
You are right, I forgot that the html controls do not support databinding.
Actually since it is one row being bound to one control, I would not
databind, I would just set the href, using the attributes collection. You
could also set the text of the hyperlink the same way.

CreateServiceLi nk.Attributes["href"] = SingleRow["FIELD NAME? / FIELD
INEX?"];
CreateServiceLi nk.InnerText = SingleRow["FIELD NAME? / FIELD INDEX?"];
"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Using Asp.net v1.1 btw.

I can't do this:

protected System.Web.UI.H tmlControls.Htm lGenericControl
CreateServiceLi nk;

DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
CreateServiceLi nk.DataSource = SingleRow;

Why can't I do this? Because DataSource is not a member of
HtmlGenericCont rol.

I also can not do:

CreateServiceLi nk.DataItem = SingleRow;

since, again, DataItem is not defined for HtmlGenericCont rol
Therefore DataItem does not get defined and I can't make this work.

<a id="CreateServi ceLink" runat="server"
href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
DataBinder.Eval (Container, "DataItem.owner _serial_num")
%>'x">Create New Service For</a>

Is there some way to define DataItem for an HtmlGenericCont rol so that
DataBinder.Eval can work?

Or is there some other mechanism to do what I want to do with an
HtmlGenericCont rol or some other HTML control?

Tim Cartwright wrote:
I believe you can add the runat="server" to any html tag, and then it can
be cast to htmlgeneric control, or one of the more specific types. So, at
that point you would be able to add the databinder code as it would be
processed server side.

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:On******** *****@TK2MSFTNG P11.phx.gbl...
Eliyahu Goldin wrote:

What is the origin of the instances you are refering to? Do they
represent
rows in a table?

Yes.
Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:eB******** ******@TK2MSFTN GP14.phx.gbl...
>I want to generate an HTML tag that will look like:
>
><a href="Equipment ServiceCreate.a spx?serial=X01" >Create New Service For

X01</a>

>or on a different instance where the user would be viewing "X05" it
>would

looke like:
><a href="Equipment ServiceCreate.a spx?serial=X05" >Create New Service For

X05</a>

>I'm trynig to figure out how to do that using HtmlGenericCont rol in C#

code behind.
>Can DataBinder.Eval work inside of plain HTML tags?
>
>I'm trying to do something like this:
>
> <a id="CreateServi ceLink" runat="server"
> href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
>DataBinder .Eval(Container , "DataItem.owner _serial_num")
> %>'x">Create New Service For</a>
>
>But what is unclear to me is what I'd bind to the CreateServiceLi nk. A

single DataRow?
>But one can not do:
>
> DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
> CreateServiceLi nk.DataSource = SingleRow;
>
>The HTMLGenericCont rol does not have DataSource as a property.
>
>So can one not do this sort of thing with plain HTML?

Nov 19 '05 #8
Make a protected property GetUrl that will obtain the correct link according
to your application logic. Databind to this property:

<a id="CreateServi ceLink" href="<%# GetUrl %>">Create New Service For</a>

Note, that runat="server" is not needed.

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. ..
Eliyahu Goldin wrote:
Then you should use a Repeater/DataList/DataGrid control, set its DataSource and DataMember properties to the table where the instancs are, put the link into the ItemTemplate and databind.
1) I know the query returns only one row.

2) I do not want to use DataGrid or similar asp controls because I do NOT

want a table. I just want a single control at the bottom of the form that is a link to a different form based on what the main record is for the current form.

Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>
wrote in message news:On******** *****@TK2MSFTNG P11.phx.gbl...
Eliyahu Goldin wrote:

What is the origin of the instances you are refering to? Do they


represent
rows in a table?

Yes.
Eliyahu

"Randall Parker" <NOtechieSPAMpu ndit_please@fut ure_avoidjunk_p undit.com>wrote in message news:eB******** ******@TK2MSFTN GP14.phx.gbl...
>I want to generate an HTML tag that will look like:
>
><a href="Equipment ServiceCreate.a spx?serial=X01" >Create New Service For
X01</a>

>or on a different instance where the user would be viewing "X05" it


would
looke like:
><a href="Equipment ServiceCreate.a spx?serial=X05" >Create New Service For
X05</a>

>I'm trynig to figure out how to do that using HtmlGenericCont rol in C#

code behind.
>Can DataBinder.Eval work inside of plain HTML tags?
>
>I'm trying to do something like this:
>
> <a id="CreateServi ceLink" runat="server"
> href="'<%# "EquipmentServi ceCreate.aspx?s erial=" +
>DataBinder. Eval(Container, "DataItem.owner _serial_num")
> %>'x">Create New Service For</a>
>
>But what is unclear to me is what I'd bind to the CreateServiceLi nk. A

single DataRow?
>But one can not do:
>
> DataRow SingleRow = dsTheSingleItem DataSet.Tables[0].Rows[0];
> CreateServiceLi nk.DataSource = SingleRow;
>
>The HTMLGenericCont rol does not have DataSource as a property.
>
>So can one not do this sort of thing with plain HTML?


Nov 19 '05 #9

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

Similar topics

0
3810
by: Michelle Keys | last post by:
Subject: DataBinder.Eval Error! Server Error in '/MSPOS' Application. ------------------------------------------------------------------------ -------- DataBinder.Eval: 'System.Data.Common.DbDataRecord' does not contain a property with the name REPORTTO. Description: An unhandled exception occurred during the execution of the
0
411
by: Lauchlan M | last post by:
Hi In my aspx page HTML I have <a href='<%# DataBinder.Eval(Container.DataItem, "Name") %>'> <%# DataBinder.Eval(Container.DataItem, "Name") %> I am trying to create a hyperlink to applicationroot\FileUploads\Filename.FileExtension.
1
3082
by: Jeronimo Bertran | last post by:
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:
4
2486
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 head around which syntax to use when specifying which field to bind to the DataGrid. I have tried <%# DataBinder.Eval( Container.DataItem, "Group.FieldName" ) %>
1
2234
by: Mike Lerch | last post by:
Pretty much, TSIA, but I'll expand a bit: I'm still trying to get my head around the n-tier approach to web design. It seems to me that when you use DataBinder.Eval in the ASPX that your tiers aren't fully separated. If you're displaying data in a DataGrid, is it appropriate to define a label in your template column as <asp:Label runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "MyField")%>' /> or is it better to do that...
3
1855
by: Patrick Olurotimi Ige | last post by:
Does this work in C# too? <%# SomeFunc(DataBinder.Eval(Containter.DataItem, "ColName")%> *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
1
2002
by: Nathan Sokalski | last post by:
I want to make an email link using databinding. I am able to get and display the email address from the database it is stored in using databinding as follows: <asp:HyperLink id="lnkEmail1" runat="server" NavigateUrl='<%# DataBinder.Eval(Container, "DataItem.email") %>' Target="_blank"><%# DataBinder.Eval(Container, "DataItem.email") %></asp:HyperLink> However, you will notice that because the NavigateUrl attribute is the same as the...
0
1005
by: Bryan | last post by:
I was wondering if it's possible to use the <%# DataBinder.Eval(Container.DataItem, "Image") %> with and html image control (img) and not use a repeater? How would it be possible to use and img control and bing the html img control throught the code behind?
4
7339
by: CharlesA | last post by:
a general question... I'm a bit mystified by Databinder.eval(object, Colname, ) if controls can be bound to their individual data sources within the load event of the page... why would we ever use this quite inelegant OO code wrapped in #<% %> inside the markup? secondly: sometimes you see simliar code inside the markup without calls to
0
8428
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
8335
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
8747
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...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7356
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
2752
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
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
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.