|
-
May 28th, 2007, 10:59 AM
#1
SqedlDataReader - no data is being displayed
Hi...
SqlDataReader holds the data from MS SQL - after it is bind to DataList, Repeater web-control i'm using the same sqlDataReader object to bound to gridview control, but no data is being displayed in gridview control..
if sqldatareader object is first bind to gridview, data is shown only in grid and not in DataList or Repeater control...
i.e. either data is being displayed in DataList/Repeater or gridview
Any problem in code?
Thanks in adv
ASPX code
PHP Code:
<asp:repeater id=repNews runat="server">
<HeaderTemplate>
Title
</HeaderTemplate>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Title") %>
</ItemTemplate>
</asp:repeater>
<asp:datalist runat="server" id=dlNews>
<ItemTemplate>
<%# Eval("Title")%>
</ItemTemplate>
</asp:datalist>
<asp:gridview id=gvNews runat="server"></asp:gridview>
page behind code
PHP Code:
SqlDataReader drNews;
SqlCommand sqlCmd = new SqlCommand();
sqlCmd.CommandType = CommandType.StoredProcedure;
sqlCmd.CommandText = "GetNewsList";
sqlCmd.Connection = new SqlConnection();
sqlCmd.Connection.ConnectionString = ConfigurationManager.AppSettings["SQLCon"].ToString();
sqlCmd.Connection.Open();
drNews = sqlCmd.ExecuteReader();
dlNews.DataSource = drNews;
dlNews.DataBind();
repNews.DataSource = drNews;
repNews.DataBind();
gvNews.DataSource = drNews;
gvNews.DataBind();
Venu Bharadwaj
"Dream it. U can do it!"
-
May 29th, 2007, 02:09 PM
#2
Re: SqedlDataReader - no data is being displayed
have you debugged this? are you getting any errors? Can you share them with us if you are?
mcm
rate my posts!
mcm
-
May 29th, 2007, 02:23 PM
#3
Re: SqedlDataReader - no data is being displayed
Yes, a DateReader is a forward only one shot reader. It can not be bound to multiple entities (the first one reads all the data )
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions 
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|