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

gridview not displaying data.

Hi I get the error (the data source for the gridview does not have any
properties from which do generate columns)
I am binding the data as follows, errors out on the databind line.
The linksDataRepository is retrieved from a session variable and is working
ok.
linksDataRepository = (List<structRepo>)Session["linksDataRepository"];
if (linksDataRepository != null)
{
gridview.DataSource = linksDataRepository;//
gridview.DataBind();
}
and for the gridview I have
<Columns>
<asp:BoundField DataField="abspath" HeaderText="absolute path" />
<asp:BoundField DataField="description" HeaderText="description" />
<asp:BoundField DataField="icount" HeaderText="Count" />
<asp:BoundField DataField="url" HeaderText="Url" />
</Columns>
as the structRepo is a structure with data abspath (string), description
(string), icount (Integer), url (string). Any ideas?
thanks.
--
Paul G
Software engineer.
Jun 27 '08 #1
4 2261
Hi Paul,

Please refer to the link below. this shows how you can bind the Grid to a
List.

http://forums.asp.net/p/1109165/1704585.aspx

Regards,
Manish
www.ComponentOne.com

"Paul" wrote:
Hi I get the error (the data source for the gridview does not have any
properties from which do generate columns)
I am binding the data as follows, errors out on the databind line.
The linksDataRepository is retrieved from a session variable and is working
ok.
linksDataRepository = (List<structRepo>)Session["linksDataRepository"];
if (linksDataRepository != null)
{
gridview.DataSource = linksDataRepository;//
gridview.DataBind();
}
and for the gridview I have
<Columns>
<asp:BoundField DataField="abspath" HeaderText="absolute path" />
<asp:BoundField DataField="description" HeaderText="description" />
<asp:BoundField DataField="icount" HeaderText="Count" />
<asp:BoundField DataField="url" HeaderText="Url" />
</Columns>
as the structRepo is a structure with data abspath (string), description
(string), icount (Integer), url (string). Any ideas?
thanks.
--
Paul G
Software engineer.
Jun 27 '08 #2
Hi,

I can see that you have some bound columns...
so after gridview's autogeneratecolumn property set to false...
suppose to solve the problem
try setting autogeneratecolumn false...
Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #3
You can databind to properties, not to structure fields.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:D3**********************************@microsof t.com...
Hi I get the error (the data source for the gridview does not have any
properties from which do generate columns)
I am binding the data as follows, errors out on the databind line.
The linksDataRepository is retrieved from a session variable and is
working
ok.
linksDataRepository = (List<structRepo>)Session["linksDataRepository"];
if (linksDataRepository != null)
{
gridview.DataSource = linksDataRepository;//
gridview.DataBind();
}
and for the gridview I have
<Columns>
<asp:BoundField DataField="abspath" HeaderText="absolute path" />
<asp:BoundField DataField="description" HeaderText="description" />
<asp:BoundField DataField="icount" HeaderText="Count" />
<asp:BoundField DataField="url" HeaderText="Url" />
</Columns>
as the structRepo is a structure with data abspath (string), description
(string), icount (Integer), url (string). Any ideas?
thanks.
--
Paul G
Software engineer.

Jun 27 '08 #4
ok I will set up properties to retrieve the structure data in the list, thanks!
--
Paul G
Software engineer.
"Eliyahu Goldin" wrote:
You can databind to properties, not to structure fields.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Paul" <Pa**@discussions.microsoft.comwrote in message
news:D3**********************************@microsof t.com...
Hi I get the error (the data source for the gridview does not have any
properties from which do generate columns)
I am binding the data as follows, errors out on the databind line.
The linksDataRepository is retrieved from a session variable and is
working
ok.
linksDataRepository = (List<structRepo>)Session["linksDataRepository"];
if (linksDataRepository != null)
{
gridview.DataSource = linksDataRepository;//
gridview.DataBind();
}
and for the gridview I have
<Columns>
<asp:BoundField DataField="abspath" HeaderText="absolute path" />
<asp:BoundField DataField="description" HeaderText="description" />
<asp:BoundField DataField="icount" HeaderText="Count" />
<asp:BoundField DataField="url" HeaderText="Url" />
</Columns>
as the structRepo is a structure with data abspath (string), description
(string), icount (Integer), url (string). Any ideas?
thanks.
--
Paul G
Software engineer.


Jun 27 '08 #5

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

Similar topics

3
by: | last post by:
Hello, I have created an ASP.NET 2.0 application that utilized a Gridview Control to display and update/delete data. The problem I am having is that the gridview control is displaying the data...
4
by: Hans Merkl | last post by:
Hi, Is there a way to show the column headers of a GridView control even if there is no data? The only thing I see is the EmptyDataTemplate but I would also like to display the column headers. ...
7
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
4
by: Jim Katz | last post by:
I have an application that updates a strongly typed data set at run time. I'd like to dynamically create a table that connects to a run time data table. For displaying the data, this works well. ...
1
by: CorporateCoder | last post by:
Hi, I am trying to bind the selected value of a databound dropdown box in a databound gridview control to the value being displayed in the template column the dropdown box has been added to. ...
5
by: srinivas | last post by:
Hi, I have binded a dataset to a gridview control at run time. I'm fetching 5 columns from the database. But while displaying it on the screen i want to show only 3 columns. I tried with...
8
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
0
by: moni | last post by:
Hi, I was hoping to know how I could get the text value of a gridview row. My code is this way: <asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"...
3
by: Polaris | last post by:
Hi Experts: I'm using asp.net 2.0 with Visual Studio 2005. I'm trying to use the GridView to display data. I need to programmatically add rows into the GridView. So far could not find a way...
10
by: gnewsgroup | last post by:
I've googled and tried various approaches, but could not resolve this problem. The article at MSDN: Displaying Images in a GridView Column only presents a simple case where all data (including the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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,...

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.