Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 6th, 2004, 12:25 AM
Authorized User
 
Join Date: Jun 2004
Posts: 54
Thanks: 0
Thanked 1 Time in 1 Post
Default ASP.Net Code Behind & In-Line Coding

hi there,

I am working with asp.net I use controls like DataGrid and DataList. I use to write code the way microsoft quick start samples showed. setting datasource and binding data I do in Code Behind and if I have to customize column appearance of DataList (specifically) I have to write it in In-Line Coding the way we used to do with Classic ASP. I always wondered, is there any way to do everything from Code Behind instead of writing some code in Code Behind and some in In-Line. I found solution for this problem as far as DataGrid is concert, but I still have problem with DataList.

If anybody explain me how to use datalist from code behind itself, it would be great help for me as In-Line Coding gets messed up. I would certainly like to see tips to use Code Behind effectively

Vinod Pawar
Software Developer
India
__________________
Vinod Pawar
United States
 
Old October 6th, 2004, 07:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

I think you are talking for binding statements such as: <%#Databinder.Eval(Container.DataItem, "Field")%>? If so, it is easiest to do it that way. You have to load a user control into a control (such as a repeater). I thought the DataList was almost the same as the DataGrid, except for being one field... what do you have to do in-line?

Coding-wise, you shouldn't have to put any code in <Script runat="server"></script> tags.

Brian
 
Old October 6th, 2004, 11:34 PM
Authorized User
 
Join Date: Jun 2004
Posts: 54
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks Brian,

you are Absolutely right, I am talking for binding statements such as: <%#Databinder.Eval(Container.DataItem, "Field")%>, and if I want this to be done in code-behind I have to use DataRepeater control, ok I shall try it. But I would also like to have suggestion from you is that What should be used > either Code-Behind or In-Line Coding or both Mixed, I am not bothered about easy or tough way of coding, but what should be the standard practice you can suggest.

thanx again

Vinod Pawar
Software Developer
India
 
Old October 7th, 2004, 07:52 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

For controls like the datalist and repeater, I would recommend using the Databinder.Eval(..) statement personally. I don't think it makes it that complicated, and it makes it easier to code. The alternative would be to manually create the databindings, which wouldn't be too bad I guess. I like to put it there because then it shortens my code-behind file, and it's ease of use. Plus, it is common to use the Databinder.Eval() statement.

In ASP.NET 2.0, it will be even easier to use. All you have to do is specify Eval("field name") or Bind("field name"). These are specified in the Page class.

Lastly, for templatecolumns in a datagrid, it definitely would be more efficient to use this notation. Otherwise, you have to bind the data in the TemplateColumn using the DataGrid's ItemCreated event, and that would be somewhat of a performance hit considering the alternative.

Brian
 
Old October 8th, 2004, 02:33 AM
Authorized User
 
Join Date: Jun 2004
Posts: 54
Thanks: 0
Thanked 1 Time in 1 Post
Default

right,

Thanx Brian..

Vinod Pawar
Software Developer
India





Similar Threads
Thread Thread Starter Forum Replies Last Post
Publish ASP.Net Code with cmd Line using Process rhd110 General .NET 0 February 2nd, 2008 03:26 PM
Macro Coding. Dropping down a line... Mikey Z Pro VB.NET 2002/2003 1 December 13th, 2007 11:08 PM
Coding scrolling text with VS 2005/ASP.NET cJeffreywang ASP.NET 2.0 Professional 6 August 15th, 2007 07:28 AM
Sending a mail from a flash with asp.net coding waikiat86 ASP.NET 2.0 Basics 3 June 28th, 2007 10:47 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.