473,320 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Idea gathering, suggestions welcome

Hi all,

I'm running an asp.net website that allows its users to log events, say
social gathewrings (with event date, time, address, descrption, etc) and
allows people to post comments on each posting. I use a datagrid with 2 cells
to display all recent events chronologically and use nested databinding to
display all related comments underneeth the events. Works great.

Now, I'm trying to make it so that I can display the most recent event on
the homepage. I ended up trying to replciate the appearence of one instance
of a datagriditem by having a table with a bunch of labels that I set
individually. I want to reuse this logic now to also show the most recent
event posted by the logged in user. So, I'm thinking user control or server
control. I'm tempted to go for a server control just to gain experience
making one. If I do go for a server control, would I encorperate databinding
into it? Does that make sense when you're only pulling data (multiple fields)
from a single datarow? What's the alternative? Just manually setting label
values in a load event, right?

Any thoughts at all would be very welcome. Thanks...

-Ben
Apr 17 '06 #1
6 1036
User controls are simpler, although not very reusable across projects.
If the control is just for this one project and you don't forsee reusing it
in other projects then I'd suggest going with a user control. Otherwise the
additional complexity of a server control may be worthwhile.
Here's more info:
http://SteveOrr.net/faq/UserCustom.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Ben R." <be**@newsgroup.nospam> wrote in message
news:C7**********************************@microsof t.com...
Hi all,

I'm running an asp.net website that allows its users to log events, say
social gathewrings (with event date, time, address, descrption, etc) and
allows people to post comments on each posting. I use a datagrid with 2
cells
to display all recent events chronologically and use nested databinding to
display all related comments underneeth the events. Works great.

Now, I'm trying to make it so that I can display the most recent event on
the homepage. I ended up trying to replciate the appearence of one
instance
of a datagriditem by having a table with a bunch of labels that I set
individually. I want to reuse this logic now to also show the most recent
event posted by the logged in user. So, I'm thinking user control or
server
control. I'm tempted to go for a server control just to gain experience
making one. If I do go for a server control, would I encorperate
databinding
into it? Does that make sense when you're only pulling data (multiple
fields)
from a single datarow? What's the alternative? Just manually setting label
values in a load event, right?

Any thoughts at all would be very welcome. Thanks...

-Ben

Apr 17 '06 #2
Hi Steve,

What about the databinding component? If I go for a server control, does my
scenario sound like a cantidate for databinding even without iteration? What
about in a user control?

-Ben

"Steve C. Orr [MVP, MCSD]" wrote:
User controls are simpler, although not very reusable across projects.
If the control is just for this one project and you don't forsee reusing it
in other projects then I'd suggest going with a user control. Otherwise the
additional complexity of a server control may be worthwhile.
Here's more info:
http://SteveOrr.net/faq/UserCustom.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Ben R." <be**@newsgroup.nospam> wrote in message
news:C7**********************************@microsof t.com...
Hi all,

I'm running an asp.net website that allows its users to log events, say
social gathewrings (with event date, time, address, descrption, etc) and
allows people to post comments on each posting. I use a datagrid with 2
cells
to display all recent events chronologically and use nested databinding to
display all related comments underneeth the events. Works great.

Now, I'm trying to make it so that I can display the most recent event on
the homepage. I ended up trying to replciate the appearence of one
instance
of a datagriditem by having a table with a bunch of labels that I set
individually. I want to reuse this logic now to also show the most recent
event posted by the logged in user. So, I'm thinking user control or
server
control. I'm tempted to go for a server control just to gain experience
making one. If I do go for a server control, would I encorperate
databinding
into it? Does that make sense when you're only pulling data (multiple
fields)
from a single datarow? What's the alternative? Just manually setting label
values in a load event, right?

Any thoughts at all would be very welcome. Thanks...

-Ben


Apr 17 '06 #3
I guess a better way to phrase the question would be:

Could you suggest what kinds of controls I should use to display the data
and a method to populate them? Would your answer differ if it were a user or
server control?

-Ben

"Ben R." wrote:
Hi Steve,

What about the databinding component? If I go for a server control, does my
scenario sound like a cantidate for databinding even without iteration? What
about in a user control?

-Ben

"Steve C. Orr [MVP, MCSD]" wrote:
User controls are simpler, although not very reusable across projects.
If the control is just for this one project and you don't forsee reusing it
in other projects then I'd suggest going with a user control. Otherwise the
additional complexity of a server control may be worthwhile.
Here's more info:
http://SteveOrr.net/faq/UserCustom.aspx

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Ben R." <be**@newsgroup.nospam> wrote in message
news:C7**********************************@microsof t.com...
Hi all,

I'm running an asp.net website that allows its users to log events, say
social gathewrings (with event date, time, address, descrption, etc) and
allows people to post comments on each posting. I use a datagrid with 2
cells
to display all recent events chronologically and use nested databinding to
display all related comments underneeth the events. Works great.

Now, I'm trying to make it so that I can display the most recent event on
the homepage. I ended up trying to replciate the appearence of one
instance
of a datagriditem by having a table with a bunch of labels that I set
individually. I want to reuse this logic now to also show the most recent
event posted by the logged in user. So, I'm thinking user control or
server
control. I'm tempted to go for a server control just to gain experience
making one. If I do go for a server control, would I encorperate
databinding
into it? Does that make sense when you're only pulling data (multiple
fields)
from a single datarow? What's the alternative? Just manually setting label
values in a load event, right?

Any thoughts at all would be very welcome. Thanks...

-Ben


Apr 17 '06 #4
Hi Ben,

Regarding on the ASP.NET application, are you developing upon ASP.NET 1.X
or 2.0? Based on my understanding, ASP.NET 2.0 has provided some good
databound controls for displaying single datarow, like FormView or
DetailsView, you can use them to bound with a DataSource(DataTable ,
collection) with single item... Also, other template databound control
like repeater or datalist can also be used to bind with single row
datasource :).

And as for using UserControl, I think it a good approach, you can add those
control which you want to bound with data field into the usercontrol(ascx
template) and then apply databinding expression on their properties. At
runtime, you can just populate a certain page level property and call the
page or usercontrol's DataBind method to evaluate those databinding
expressions. e.g:

==========aspx page ===
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1"
runat="server"></asp:SqlDataSource>

</div>
<asp:Label ID="Label1" runat="server"
Text="CategoryID:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
category.CategoryID %>'></asp:TextBox><br />
<asp:Label ID="Label2" runat="server"
Text="CategoryName:"></asp:Label><asp:TextBox
ID="TextBox2" runat="server" Text='<%# category.CategoryName
%>'></asp:TextBox><br />
<asp:Label ID="Label3" runat="server"
Text="Description:"></asp:Label><asp:TextBox
ID="TextBox3" runat="server" Text='<%# category.Description
%>'></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="Button1_Click" />
</form>
========code behind==========
public partial class _Default : System.Web.UI.Page
{
protected CategoryDS.CategoriesDataTable dt;
protected CategoryDS.CategoriesRow category;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CategoryDSTableAdapters.CategoriesTableAdapter ta = new
CategoryDSTableAdapters.CategoriesTableAdapter();

dt = ta.GetData();
category = dt.Rows[0] as CategoryDS.CategoriesRow;
Page.DataBind();
}
}
========================
In the above code I just use a page variable as datasource and put those
controls at page level, you can encapsulate them into UserControl and just
call usercontrol.DataBind, that can make the databinding processing only
occur at the usercontrol scope.

Hope this also helps.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Apr 18 '06 #5
Hi Steven,

Your insights are very helpful. Indeed this is on .NET 2.0 so I do have
those options. I didn't actually consider using a repeater bound to only a
single row. Is that considered an ok programming practice?

I'm not sure I follow your comments about a user control. You seem to
suggest a usercontrol as an ascx template. Do you mean that I should use a
templated control and pull a template from an ascx file? Also:
At runtime, you can just populate a certain page level property and call the
page or usercontrol's DataBind method to evaluate those databinding
expressions.
Which "pagelevel property" in the example are you takling about?

Thanks...

-Ben

"Steven Cheng[MSFT]" wrote:
Hi Ben,

Regarding on the ASP.NET application, are you developing upon ASP.NET 1.X
or 2.0? Based on my understanding, ASP.NET 2.0 has provided some good
databound controls for displaying single datarow, like FormView or
DetailsView, you can use them to bound with a DataSource(DataTable ,
collection) with single item... Also, other template databound control
like repeater or datalist can also be used to bind with single row
datasource :).

And as for using UserControl, I think it a good approach, you can add those
control which you want to bound with data field into the usercontrol(ascx
template) and then apply databinding expression on their properties. At
runtime, you can just populate a certain page level property and call the
page or usercontrol's DataBind method to evaluate those databinding
expressions. e.g:

==========aspx page ===
<form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1"
runat="server"></asp:SqlDataSource>

</div>
<asp:Label ID="Label1" runat="server"
Text="CategoryID:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Text='<%#
category.CategoryID %>'></asp:TextBox><br />
<asp:Label ID="Label2" runat="server"
Text="CategoryName:"></asp:Label><asp:TextBox
ID="TextBox2" runat="server" Text='<%# category.CategoryName
%>'></asp:TextBox><br />
<asp:Label ID="Label3" runat="server"
Text="Description:"></asp:Label><asp:TextBox
ID="TextBox3" runat="server" Text='<%# category.Description
%>'></asp:TextBox><br />
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="Button1_Click" />
</form>
========code behind==========
public partial class _Default : System.Web.UI.Page
{
protected CategoryDS.CategoriesDataTable dt;
protected CategoryDS.CategoriesRow category;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
CategoryDSTableAdapters.CategoriesTableAdapter ta = new
CategoryDSTableAdapters.CategoriesTableAdapter();

dt = ta.GetData();
category = dt.Rows[0] as CategoryDS.CategoriesRow;
Page.DataBind();
}
}
========================
In the above code I just use a page variable as datasource and put those
controls at page level, you can encapsulate them into UserControl and just
call usercontrol.DataBind, that can make the databinding processing only
occur at the usercontrol scope.

Hope this also helps.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


Apr 18 '06 #6
Thanks for your response Ben,

============================
I'm not sure I follow your comments about a user control.
=============================

I mean you can just put some simple control markup with databinding
expression(like the one I posted in former message) in a usercontrol and
use that usercontrol in your page. Also, you can directly put such markup
in main page as I did.

And in my markup snippet, you can see that I use databinding expression
(<%# .....%) to bind control properties with databound objects. e.g:

================
asp:TextBox ID="TextBox1" runat="server" Text='<%# category.CategoryID
%>'></asp:TextBox><br />
==============

And the "category" object is just a Page level variable which I defined in
page's codebehind class to act as the DataSource object for databinding.

======in code behind========
public partial class _Default : System.Web.UI.Page
{
protected CategoryDS.CategoriesDataTable dt;
protected CategoryDS.CategoriesRow category;
.......................
===============

In addition, as for use singleRow DataSource to bind with Repeater or other
List DataBound control, I think it ok and there is not violation against
any best practice.

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support
==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.

Apr 19 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

50
by: 127.0.0.1 | last post by:
With all the problems with having register_globals = on, I propose the following idea: We define register_globals_manual = on as a new configuration default. What this does is enable 3 new...
4
by: Justin Koivisto | last post by:
On 10/06/2003 11:50 AM CST, the OP, 127.0.0.1, wrote: > httpget $user_id; > httppost $credit_card; > session $really_important_stuff; > > Each of these declaration lines would effectively enable...
2
by: Eric.Jones | last post by:
I'm trying to assist in analyzing a deadlock situation that sometimes occurs on a UDB/AIX system. We have several java applications that connect via jdbc contending for a workflow table on the...
0
by: Dougie | last post by:
I have a system that I'm working on to collect and analyse bowling scores. The data is in XML format, and I really want to provide some statistics on a previous rounds etc. I've looked into...
2
by: John Wood | last post by:
I'm just considering embarking on writing a class that does a better job than the Serialize attribute. The serialize attribute is no good because it sucks at even the most basic of versioning. So...
1
by: Mike | last post by:
I have the following: 1 x .NET 2.0 .DLL Containing one public DataSet (CustomerHandler) which contains one table and a tableadapter to fill a datatable 1 x .NET 2.0 EXE With a single...
0
by: eight02645999 | last post by:
hi i am working on cgi and wish to gather some input on correct/often used methods of what i am going to do. I need to let the user choose (in the form of check boxes) whether they need the data...
2
by: Edwin Knoppert | last post by:
So far i had some info that IIS6 is much better then 5 and before. For discussion over here i need to gather some information how to secure our IIS6 webserver and data. Suggestions? (Been...
0
by: Krypto | last post by:
I am 3 months old to python and I have done some small projects. I want to build a Peer to Peer streaming client ..something like BitTorrent. I know it is daunting but I got to start somewhere....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.