For some reason the following simple code returns "System.Web.HttpException:
The IListSource does not contain any data sources." on the DataBind() call.
Anyone got any ideas? (Note the ASP.Net page has a datagrid and a sql connec
tion.
Brian Taylor
private void Page_Load(object sender, System.EventArgs e)
{
SqlCommand cmd = new SqlCommand( "select top 1 * from pubs..authors", connec
tion );
connection.Open();
dataGrid1.DataSource = cmd.ExecuteReader();
dataGrid1.DataBind();
connectione.Close();
}Hi Brian,
As for the problem you mentioned, I think we can first check the data
accessing steps since the error information indicate that the IListSource
dosen't contain datasource. We can execute the sqlcommand separately to see
whether it return the correct set of records
Also, we can manually create a DataTable with some test datas and bound to
the datagrid to see whether the problem is concerned with grid.
If you have any other questions ,please feel free to post here. Thanks.
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Steven,
Thanks very much for your information. I looked at the problem and checked
all the things you mentioned. I found that the datagrid binding had some
test values I had fogotten to correct - silly me!
Thanks very much for your suggestions.
Brian
"Steven Cheng[MSFT]" <v-schang@.online.microsoft.com> wrote in message
news:lMEgkyNrEHA.3356@.cpmsftngxa06.phx.gbl...
> Hi Brian,
> As for the problem you mentioned, I think we can first check the data
> accessing steps since the error information indicate that the IListSource
> dosen't contain datasource. We can execute the sqlcommand separately to
> see
> whether it return the correct set of records
> Also, we can manually create a DataTable with some test datas and bound to
> the datagrid to see whether the problem is concerned with grid.
> If you have any other questions ,please feel free to post here. Thanks.
> Regards,
> Steven Cheng
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
Hi Brian,
You're Welcome, I'm also glad that my suggestions are of assistance. Thanks
again for your posting and please always feel free to post here when you
meet any other problems on aspnet.:)
Regards,
Steven Cheng
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
Saturday, March 24, 2012
Simple datagrid population problem
Labels:
asp,
code,
contain,
databind,
datagrid,
following,
httpexception,
ilistsource,
net,
population,
returns,
sources,
system,
web
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment