Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Databind a label outside of clasic data controls (DataList, Repeater, GridView, etc)

Reply
Thread Tools

Databind a label outside of clasic data controls (DataList, Repeater, GridView, etc)

 
 
craigkenisston@hotmail.com
Guest
Posts: n/a
 
      09-15-2006
In Asp.Net 2.0 I need to create a very special layout with data coming
from an ObjectDataSource.
It was already working using a GridView, but I need a free layout.
So, I dropped the GridView and added something like this:

So, I'm trying something like :
<div>
<table>
<tr>
<td>
Referring URL:</td>
<td>
<asp:label id="lblReferringURL" runat="server"
text='<%# DataBinder.Eval(ObjectDataSource1, "CTRY_CODE") %>'>
</asp:label>
</td>
</tr>
<tr>
<td>
Entry Page:</td>
<td>
<asp:label id="lblEntryPage" runat="server" text='<%#
DataBinder.Eval(ObjectDataSource1, "STAT_CODE") %>'></asp:label>
</td>
</tr>
</table>
</div>

Then I used Page.DataBind() in code behind.
I got errors telling me that there are no objects "CTRY_CODE" or
"STAT_CODE" in ObjectDataSource1.

What's the proper way to do this ?

 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      09-15-2006
Hi,

How about using a templated FormView and then bind the FormView to the
objectdatasource. Something like this:

<asp:formview id="FormView1" runat="server"
datasourceid="ObjectDataSource1">
<itemtemplate>
<div>
<table>
<tr>
<td>Referring URL:</td>
<td>
<asp:label id="lblReferringURL"
runat="server" text='<%# Eval("CTRY_CODE") %>'>
</asp:label>
</td>
</tr>
<tr>
<td>Entry Page:</td>
<td>
<asp:label id="lblEntryPage"
runat="server" text='<%# Eval("STAT_CODE") %>'></asp:label>
</td>
</tr>
</table>
</div>
</itemtemplate>
</asp:formview>

Not sure this is what you're after, but thought I'd suggest it.

Ken
Microsoft MVP [ASP.NET]


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
> In Asp.Net 2.0 I need to create a very special layout with data coming
> from an ObjectDataSource.
> It was already working using a GridView, but I need a free layout.
> So, I dropped the GridView and added something like this:
>
> So, I'm trying something like :
> <div>
> <table>
> <tr>
> <td>
> Referring URL:</td>
> <td>
> <asp:label id="lblReferringURL" runat="server"
> text='<%# DataBinder.Eval(ObjectDataSource1, "CTRY_CODE") %>'>
> </asp:label>
> </td>
> </tr>
> <tr>
> <td>
> Entry Page:</td>
> <td>
> <asp:label id="lblEntryPage" runat="server" text='<%#
> DataBinder.Eval(ObjectDataSource1, "STAT_CODE") %>'></asp:label>
> </td>
> </tr>
> </table>
> </div>
>
> Then I used Page.DataBind() in code behind.
> I got errors telling me that there are no objects "CTRY_CODE" or
> "STAT_CODE" in ObjectDataSource1.
>
> What's the proper way to do this ?
>



 
Reply With Quote
 
 
 
 
craigkenisston@hotmail.com
Guest
Posts: n/a
 
      09-16-2006

Thank you !


Ken Cox [Microsoft MVP] wrote:
> Hi,
>
> How about using a templated FormView and then bind the FormView to the
> objectdatasource. Something like this:
>
> <asp:formview id="FormView1" runat="server"
> datasourceid="ObjectDataSource1">
> <itemtemplate>
> <div>
> <table>
> <tr>
> <td>Referring URL:</td>
> <td>
> <asp:label id="lblReferringURL"
> runat="server" text='<%# Eval("CTRY_CODE") %>'>
> </asp:label>
> </td>
> </tr>
> <tr>
> <td>Entry Page:</td>
> <td>
> <asp:label id="lblEntryPage"
> runat="server" text='<%# Eval("STAT_CODE") %>'></asp:label>
> </td>
> </tr>
> </table>
> </div>
> </itemtemplate>
> </asp:formview>
>
> Not sure this is what you're after, but thought I'd suggest it.
>
> Ken
> Microsoft MVP [ASP.NET]
>
>
> <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
> > In Asp.Net 2.0 I need to create a very special layout with data coming
> > from an ObjectDataSource.
> > It was already working using a GridView, but I need a free layout.
> > So, I dropped the GridView and added something like this:
> >
> > So, I'm trying something like :
> > <div>
> > <table>
> > <tr>
> > <td>
> > Referring URL:</td>
> > <td>
> > <asp:label id="lblReferringURL" runat="server"
> > text='<%# DataBinder.Eval(ObjectDataSource1, "CTRY_CODE") %>'>
> > </asp:label>
> > </td>
> > </tr>
> > <tr>
> > <td>
> > Entry Page:</td>
> > <td>
> > <asp:label id="lblEntryPage" runat="server" text='<%#
> > DataBinder.Eval(ObjectDataSource1, "STAT_CODE") %>'></asp:label>
> > </td>
> > </tr>
> > </table>
> > </div>
> >
> > Then I used Page.DataBind() in code behind.
> > I got errors telling me that there are no objects "CTRY_CODE" or
> > "STAT_CODE" in ObjectDataSource1.
> >
> > What's the proper way to do this ?
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Clasic Battle Nikon versus Canon Toxic Digital Photography 3 12-12-2009 04:37 PM
help with pix inside->outside + dmz->outside + inside->outside->dmz Jack Cisco 0 09-19-2007 01:57 AM
Clasic ASP Connection String Prabhat ASP General 4 03-11-2005 07:49 AM
Clasic ASP Connection String Prabhat Nath ASP .Net 12 03-11-2005 07:49 AM
BUG in DataBind? After .DataBind there are more DataGrid Items than DataSet Rows! Michael ASP .Net Datagrid Control 0 12-29-2003 07:47 PM



Advertisments