TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
rra
NA
2
0
DataList doesn't display
Oct 3 2003 10:25 AM
I am trying to display a simple datalist and datagrid on a webform, the datagrid display properly but the datalist doesn’t. I tried to get the datalist only but still it doesn’t work. I don’t get any error message/Exception. My code: private void Page_Load(object sender, System.EventArgs e) { // Put user code to initialize the page here string sql = "SELECT * FROM aEvents"; SqlConnection m_SqlConnection = new SqlConnection(CDb.DsnEvents); SqlCommand myCommand = new SqlCommand(sql,m_SqlConnection); SqlDataReader myDataReader; try { m_SqlConnection.Open(); myDataReader = myCommand.ExecuteReader(); DataList1.DataSource = myDataReader; DataGrid1.DataSource = myDataReader; DataGrid1.DataBind(); DataList1.DataBind(); m_SqlConnection.Close(); } catch (Exception myException) { Response.Write("An error has occurred: " + myException.ToString()); } }
Reply
Answers (
1
)
A helpful code sample for binding a collection to a datagrid
C# and .NET framework