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

See no DataList

I created an ASP.NET project and dropped a DataList on
the web form. I then wrote a simple class to return data:

namespace Playing
{
public class PositionData
{
private string name;
private string ticker;

public PositionData(string name, string ticker)
{
this.name = name;
this.ticker = ticker;
}

public string Name
{
get { return name; }
}

public string Ticker
{
get { return ticker; }
}
}

I then inserted the code to load data into the DataList

private void Page_Load(object sender, System.EventArgs
e)
{
if (!IsPostBack)
{
ArrayList values = new ArrayList();
values.Add(new PositionData("Microsoft", "Msft"));
values.Add(new PositionData("Intel", "Intc"));
values.Add(new PositionData("Dell", "Dell"));

DataList1.DataSource = values;
DataList1.DataBind();
}
}
}

When I run the application into IE 6, All I saw was a
blank screen with no DataList and nada. I try with
DataGrid and everything works fine.

What have I done wrong?

Thank you in advance for all your help.
Nov 18 '05 #1
6 1314
Did you actually bind the columns to the DataList? Unlike the DataGrid, you
must visit the HTML section of the webform and bind the datafield/property
to each column in the list, whereas the datagrid will "draw" the data based
on the datafield property set in the designer.

HTH,

Morgan

"Thanh" <an*******@discussions.microsoft.com> wrote in message
news:03****************************@phx.gbl...
I created an ASP.NET project and dropped a DataList on
the web form. I then wrote a simple class to return data:

namespace Playing
{
public class PositionData
{
private string name;
private string ticker;

public PositionData(string name, string ticker)
{
this.name = name;
this.ticker = ticker;
}

public string Name
{
get { return name; }
}

public string Ticker
{
get { return ticker; }
}
}

I then inserted the code to load data into the DataList

private void Page_Load(object sender, System.EventArgs
e)
{
if (!IsPostBack)
{
ArrayList values = new ArrayList();
values.Add(new PositionData("Microsoft", "Msft"));
values.Add(new PositionData("Intel", "Intc"));
values.Add(new PositionData("Dell", "Dell"));

DataList1.DataSource = values;
DataList1.DataBind();
}
}
}

When I run the application into IE 6, All I saw was a
blank screen with no DataList and nada. I try with
DataGrid and everything works fine.

What have I done wrong?

Thank you in advance for all your help.

Nov 18 '05 #2
Are these lines of code bind the DataList to its source?

DataList1.DataSource = values;
DataList1.DataBind();

According to the help files and everything I have
searched on the NET including MSDN indicates so. The code
posted in my first post was indeed coming from the sample
provided by Microsoft.

Thanh
-----Original Message-----
Did you actually bind the columns to the DataList? Unlike the DataGrid, youmust visit the HTML section of the webform and bind the datafield/propertyto each column in the list, whereas the datagrid will "draw" the data basedon the datafield property set in the designer.

HTH,

Morgan

"Thanh" <an*******@discussions.microsoft.com> wrote in messagenews:03****************************@phx.gbl...
I created an ASP.NET project and dropped a DataList on
the web form. I then wrote a simple class to return data:
namespace Playing
{
public class PositionData
{
private string name;
private string ticker;

public PositionData(string name, string ticker)
{
this.name = name;
this.ticker = ticker;
}

public string Name
{
get { return name; }
}

public string Ticker
{
get { return ticker; }
}
}

I then inserted the code to load data into the DataList

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
ArrayList values = new ArrayList();
values.Add(new PositionData ("Microsoft", "Msft")); values.Add(new PositionData("Intel", "Intc"));
values.Add(new PositionData("Dell", "Dell"));

DataList1.DataSource = values;
DataList1.DataBind();
}
}
}

When I run the application into IE 6, All I saw was a
blank screen with no DataList and nada. I try with
DataGrid and everything works fine.

What have I done wrong?

Thank you in advance for all your help.

.

Nov 18 '05 #3
Yes, that will bind the data to the datalist, but you also need the
following added to your HTML ...
ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconbindingsqldatatodatalistcontro
l.htm

<body>
<%-- Open the DataList control and set it for two columns, to be
filled in horizontal order. --%>
<ASP:DataList id="MyDataList" RepeatColumns="2"
RepeatDirection="Horizontal" runat="server">
<ItemTemplate>
<div style="padding:15,15,15,15;font-size:10pt;font-family:Verdana">
<div style="font:12pt verdana;color:darkred">
<i><b><%# DataBinder.Eval(Container.DataItem, "title")%>
</i></b>
</div>
<br>
<b>Title ID: </b>
<%# DataBinder.Eval(Container.DataItem, "title_id") %><br>
<b>Category: </b>
<%# DataBinder.Eval(Container.DataItem, "type")%><br>
<b>Publisher ID: </b>
<%# DataBinder.Eval(Container.DataItem, "pub_id") %><br>
<b>Price: </b>
<%# DataBinder.Eval(Container.DataItem, "price", "{0:c}") %>
<p>
</div>
</ItemTemplate>
</ASP:DataList>
</body>

"Thanh" <an*******@discussions.microsoft.com> wrote in message
news:08****************************@phx.gbl...
Are these lines of code bind the DataList to its source?

DataList1.DataSource = values;
DataList1.DataBind();

According to the help files and everything I have
searched on the NET including MSDN indicates so. The code
posted in my first post was indeed coming from the sample
provided by Microsoft.

Thanh
-----Original Message-----
Did you actually bind the columns to the DataList?

Unlike the DataGrid, you
must visit the HTML section of the webform and bind the

datafield/property
to each column in the list, whereas the datagrid

will "draw" the data based
on the datafield property set in the designer.

HTH,

Morgan

"Thanh" <an*******@discussions.microsoft.com> wrote in

message
news:03****************************@phx.gbl...
I created an ASP.NET project and dropped a DataList on
the web form. I then wrote a simple class to return data:
namespace Playing
{
public class PositionData
{
private string name;
private string ticker;

public PositionData(string name, string ticker)
{
this.name = name;
this.ticker = ticker;
}

public string Name
{
get { return name; }
}

public string Ticker
{
get { return ticker; }
}
}

I then inserted the code to load data into the DataList

private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
ArrayList values = new ArrayList();
values.Add(new PositionData ("Microsoft", "Msft")); values.Add(new PositionData("Intel", "Intc"));
values.Add(new PositionData("Dell", "Dell"));

DataList1.DataSource = values;
DataList1.DataBind();
}
}
}

When I run the application into IE 6, All I saw was a
blank screen with no DataList and nada. I try with
DataGrid and everything works fine.

What have I done wrong?

Thank you in advance for all your help.

.

Nov 18 '05 #4
Thanks again Morgan for your help. I finally understand
what it really takes to populate the DataList and
Repeater web server controls with Data. In my opinion,
it's a very complicated and cumbersome process to have to
manually insert code into the HTML file to make it works.
It's not a user friendly way at all.

Thanh
-----Original Message-----
Yes, that will bind the data to the datalist, but you also need thefollowing added to your HTML ...
ms- help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconbindingsqldatat
odatalistcontrol.htm

<body>
<%-- Open the DataList control and set it for two columns, to be filled in horizontal order. --%>
<ASP:DataList id="MyDataList" RepeatColumns="2"
RepeatDirection="Horizontal" runat="server">
<ItemTemplate>
<div style="padding:15,15,15,15;font- size:10pt;font-family:Verdana"> <div style="font:12pt verdana;color:darkred">
<i><b><%# DataBinder.Eval (Container.DataItem, "title")%> </i></b>
</div>
<br>
<b>Title ID: </b>
<%# DataBinder.Eval (Container.DataItem, "title_id") %><br> <b>Category: </b>
<%# DataBinder.Eval(Container.DataItem, "type")%
<br>
<b>Publisher ID: </b>
<%# DataBinder.Eval(Container.DataItem, "pub_id") %
<br>
<b>Price: </b>
<%# DataBinder.Eval (Container.DataItem, "price", "{0:c}") %> <p>
</div>
</ItemTemplate>
</ASP:DataList>
</body>


Nov 18 '05 #5
Agreed there is more work involved, but you reduce the server-side (client
side, as well) overhead by not using the DataGrid control. I've gotten into
the habit of creating a single page with the DataList &/or Repeater control
and doing a copy-paste into new pages and making changes as needed. Takes
out the redundant work (for the most part...) involved with the controls

"Thanh" <an*******@discussions.microsoft.com> wrote in message
news:02****************************@phx.gbl...
Thanks again Morgan for your help. I finally understand
what it really takes to populate the DataList and
Repeater web server controls with Data. In my opinion,
it's a very complicated and cumbersome process to have to
manually insert code into the HTML file to make it works.
It's not a user friendly way at all.

Thanh
-----Original Message-----
Yes, that will bind the data to the datalist, but you

also need the
following added to your HTML ...
ms-

help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconbindingsqldatat
odatalistcontro
l.htm

<body>
<%-- Open the DataList control and set it for two

columns, to be
filled in horizontal order. --%>
<ASP:DataList id="MyDataList" RepeatColumns="2"
RepeatDirection="Horizontal" runat="server">
<ItemTemplate>
<div style="padding:15,15,15,15;font-

size:10pt;font-family:Verdana">
<div style="font:12pt verdana;color:darkred">
<i><b><%# DataBinder.Eval

(Container.DataItem, "title")%>
</i></b>
</div>
<br>
<b>Title ID: </b>
<%# DataBinder.Eval

(Container.DataItem, "title_id") %><br>
<b>Category: </b>
<%# DataBinder.Eval(Container.DataItem, "type")%
<br>
<b>Publisher ID: </b>
<%# DataBinder.Eval(Container.DataItem, "pub_id") %
<br>
<b>Price: </b>
<%# DataBinder.Eval

(Container.DataItem, "price", "{0:c}") %>
<p>
</div>
</ItemTemplate>
</ASP:DataList>
</body>

Nov 18 '05 #6
Copy and paste is a good idea. By the time I gain more
knowledge about how DataList and Repeater work, I would
like to build an inherited web control to automate this
tedious process of populating the data.

Thanks again Morgan.

Merry Christmas and Happy New Year

Thanh
-----Original Message-----
Agreed there is more work involved, but you reduce the server-side (clientside, as well) overhead by not using the DataGrid control. I've gotten intothe habit of creating a single page with the DataList &/or Repeater controland doing a copy-paste into new pages and making changes as needed. Takesout the redundant work (for the most part...) involved with the controls
"Thanh" <an*******@discussions.microsoft.com> wrote in messagenews:02****************************@phx.gbl...
Thanks again Morgan for your help. I finally understand
what it really takes to populate the DataList and
Repeater web server controls with Data. In my opinion,
it's a very complicated and cumbersome process to have to manually insert code into the HTML file to make it works. It's not a user friendly way at all.

Thanh
>-----Original Message-----
>Yes, that will bind the data to the datalist, but you

also need the
>following added to your HTML ...
>ms-

help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconbindingsqldatat odatalistcontro
>l.htm
>
><body>
> <%-- Open the DataList control and set it for two
columns, to be
> filled in horizontal order. --%>
> <ASP:DataList id="MyDataList" RepeatColumns="2"
> RepeatDirection="Horizontal" runat="server">
> <ItemTemplate>
> <div style="padding:15,15,15,15;font-

size:10pt;font-family:Verdana">
> <div style="font:12pt verdana;color:darkred">
> <i><b><%# DataBinder.Eval

(Container.DataItem, "title")%>
> </i></b>
> </div>
> <br>
> <b>Title ID: </b>
> <%# DataBinder.Eval

(Container.DataItem, "title_id") %><br>
> <b>Category: </b>
> <%# DataBinder.Eval(Container.DataItem, "type")%
><br>
> <b>Publisher ID: </b>
> <%# DataBinder.Eval

(Container.DataItem, "pub_id") % ><br>
> <b>Price: </b>
> <%# DataBinder.Eval

(Container.DataItem, "price", "{0:c}") %>
> <p>
> </div>
> </ItemTemplate>
> </ASP:DataList>
></body>
>

.

Nov 18 '05 #7

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

Similar topics

1
by: pete K | last post by:
Is it possible in asp.net to have a datalist in the itemtemplate of another datalist? For example: <asp:datalist id="MyList" runat="server"> <ItemTemplate> <table border="0" width="300">...
4
by: V. Jenks | last post by:
What seems like a simple thing is apparently not so straightforward? I have a datalist. Inside of that datalist is an <itemtemplate> secion which contains other server controls such as a...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
6
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
0
by: Les Caudle | last post by:
I have a menu system composed of a DataList nested inside a DataList. The outer DataList has it's DataSource (composed of a DataSet with two tables linked by a CategoryPagesRelation Relation) set...
1
by: AJ | last post by:
Hi all, With the following code in mind : <asp:DataList ID="dlOne" DataKeyField="myField1" DataSource="<%# GetDataSource1()" Runat="server"> <ItemTemplate> Output Value Here! <asp:DataList...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
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
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: 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
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
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...
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...
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,...
0
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...

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.