Go Back   SitePoint Forums > Forum Index > Program Your Site > .NET
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old Jul 27, 2004, 06:22   #1
ArticleBot
SitePoint Articles
 
ArticleBot's Avatar
 
Join Date: Apr 2001
Posts: 0
Article Discussion

This is an article discussion thread for discussing the SitePoint article, "Using the ASP.NET Repeater Control"
ArticleBot is offline   Reply With Quote
Old Jan 2, 2005, 17:21   #2
cringer
SitePoint Guru
 
Join Date: Sep 2004
Location: NY, USA
Posts: 710
Repeaters are cool, no doubt, as are datagrids and datalists.
Databinding in .NET is a real pleasure, Makes life easy compared to procedural scripting languages such as PHP or old classic ASP.

But this bit I really don't understand:

Quote:
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conDotNet = new SqlConnection
"Server=xxxxxxx;UID=xxxx;PWD=xxxxx;Database=DotNetGenius");
string sSQL = "Select sub_category_id, sub_category_text
from Sub_Category";
SqlCommand cmd = new SqlCommand(sSQL, conDotNet);
conDotNet.Open();
SqlDataReader dtrCat = cmd.ExecuteReader();
catlist.DataSource = dtrCat;
catlist.DataBind();
}
Your'e exposing your database connection object through every single page? Wouldn't you want to centralize and reuse that object in a class for reasons I shouldn't have to review here?

Also if using MS-SQL Server... why wouldn't you use functions that call stored procedures and return an sqldatareader (as part of the database class), instead of sending raw SQL strings from random pages to the database?

Maybe I'm nitpicking and maybe you illustrated in this way for simplicity's sake. But to me that's just bad practice.
cringer is offline   Reply With Quote
Old Jun 22, 2006, 08:38   #3
pufa
SitePoint Guru
 
pufa's Avatar
 
Join Date: Oct 2004
Location: Portugal, Lisboa
Posts: 822
Instead of :
NavigateUrl='<%# "mainframeset.aspx?CatType=" + DataBinder.Eval(Container.DataItem,"Sub_Category_ID")%>"

You can use another overload of DataBinder.Eval

<%# DataBinder.Eval(Container.DataItem, "Sub_Category_ID", "mainframeset.aspx?CaType={0}") %>, much cleaner.

{0}, gets replacled with the value of "Sub_Category_ID", and DataBinder.Eval returns

mainframeset.aspx?CatType=Sub_Category_ID_Value
pufa is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 01:42.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved