Hey all,
I am developing a workshop registration system, and am new to ASP .NET.
On my first page, I want to list the "categories " available along with the
number of "workshops" related to that category. I have it working, but want
to know if there is a better way to do this. I have listed the code below,
any help would be VERY much appreciated.
----- CODE FOR MAIN PAGE -----
<%@ Page Language="vb" AutoEventWireup ="false"
Codebehind="wor kshop_registrat ion_system.aspx .vb"
Inherits="Works hop_Registratio n_System.Worksh op_Registration _System"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Worksh op Registration System | View Categories</title>
<meta content="Micros oft Visual Studio .NET 7.1" name="GENERATOR ">
<meta content="Visual Basic .NET 7.1" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
</HEAD>
<body MS_POSITIONING= "FlowLayout ">
<form id="Form1" method="post" runat="server">
<p align="center"> <font face="Arial" color="#800000" size="4"><b>Wel come
to the IUSD
Workshop Registration System, v1.00</b></font></p>
<p align="center"> <asp:datalist id="dlWorkshop_ Category_Select ions"
runat="server" BorderColor="#C C9966" BorderStyle="No ne"
BorderWidth="1p x" BackColor="Whit e" CellPadding="2" GridLines="Both "
Width="500px" RepeatColumns=" 2">
<SelectedItemSt yle Font-Bold="True" Wrap="False" ForeColor="#663 399"
BackColor="#FFC C66"></SelectedItemSty le>
<HeaderTemplate >
Please select a workshop category from below
</HeaderTemplate>
<ItemStyle Font-Size="10pt" Font-Names="Arial" Wrap="False"
ForeColor="#330 099" BackColor="Whit e"></ItemStyle>
<ItemTemplate >
<A href='<%# Databinder.Eval (Container.Data Item, "ID",
"view_category. aspx?workshop_c ategory_id={0}& category_name=" ) %><%#
Databinder.Eval (Container.Data Item, "Short_Name ") %> '>
<asp:Label id="lblWorkshop _Category_Title " runat="server" Text='<%#
Databinder.Eval (Container.Data Item, "Short_Name ") %>'>
</asp:Label>
(<asp:Label id="lblWorkshop _Category_Works hops_Count" runat="server">
</asp:Label> workshops)</A>
</ItemTemplate>
<FooterStyle ForeColor="#330 099" BackColor="#FFF FCC"></FooterStyle>
<HeaderStyle Font-Bold="True" Wrap="False" ForeColor="#FFF FCC"
BackColor="#990 000"></HeaderStyle>
</asp:datalist></p>
</form>
</body>
</HTML>
----- CODEBEHIND FOR MAIN PAGE -----
Imports System.Data.Sql Client
Public Class Workshop_Regist ration_System
Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
End Sub
Protected WithEvents dlWorkshop_Cate gory_Selections As
System.Web.UI.W ebControls.Data List
Protected WithEvents lblWorkshop_Cat egory_Title As
System.Web.UI.W ebControls.Labe l
Protected WithEvents lblWorkshop_Cat egory_Workshops _Count As
System.Web.UI.W ebControls.Labe l
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Dim dsWorkshop_Cate gories As DataSet
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
If Not Page.IsPostBack Then
Dim daWorkshop_Cate gories As New SqlDataAdapter
daWorkshop_Cate gories =
DataHandler.Get DataAdapter("sp GetCategory_Sel ections", "Training_Syste m")
daWorkshop_Cate gories.SelectCo mmand.CommandTy pe =
CommandType.Sto redProcedure
' Create and add an output parameter to Parameters collection, then
' set the direction for the parameter. This parameter returns the Rows
returned.
daWorkshop_Cate gories.SelectCo mmand.Parameter s.Add(New
SqlParameter("@ RowCount", SqlDbType.Int, 4))
daWorkshop_Cate gories.SelectCo mmand.Parameter s("@RowCount"). Direction =
ParameterDirect ion.Output
dsWorkshop_Cate gories = New DataSet
daWorkshop_Cate gories.Fill(dsW orkshop_Categor ies,
"tblWorkshop_Ca tegories")
dsWorkshop_Cate gories.Tables(0 ).TableName = "Workshop_Categ ories"
dsWorkshop_Cate gories.Tables(1 ).TableName = "Workshop_Selec tions"
With dlWorkshop_Cate gory_Selections
.DataSource = dsWorkshop_Cate gories
.DataBind()
End With
daWorkshop_Cate gories.Dispose( )
DataHandler.Clo se_DBConn(DataH andler.cnnDBCon n)
End If
End Sub
Private Sub dlWorkshop_Cate gory_Selections _ItemDataBound( ByVal sender As
Object, ByVal e As System.Web.UI.W ebControls.Data ListItemEventAr gs) Handles
dlWorkshop_Cate gory_Selections .ItemDataBound
If e.Item.ItemType = ListItemType.It em Or e.Item.ItemType =
ListItemType.Al ternatingItem Then
Dim dvWorkshop_Sele ctions As DataView =
dsWorkshop_Cate gories.Tables(" Workshop_Select ions").DefaultV iew
dvWorkshop_Sele ctions.RowFilte r = "Workshop_Categ ory_ID = '" &
Convert.ToStrin g(CType(e.Item. DataItem, DataRowView).Ro w.Item("ID")) & "'"
Dim lblToChange As Label
lblToChange =
DirectCast(e.It em.FindControl( "lblWorkshop_Ca tegory_Workshop s_Count"),
Label)
lblToChange.Tex t = dvWorkshop_Sele ctions.Count.To String
End If
End Sub
End Class
----- SQL Stored Procedure -----
ALTER PROCEDURE dbo.spGetCatego ry_Selections
(
@RowCount int output
)
AS
SELECT ID, Short_Name, Long_Name FROM tblWorkshop_Cat egory_Selection s WHERE
(Active = 1) AND (Status_ID = 1) ORDER BY Short_Name;
SELECT @RowCount = @@ROWCOUNT
SELECT * FROM tblWorkshop_Sel ections;
RETURN 1 1125
Hi,
It's always better to developed with layer application approach. move
your access DB code from page into separate DAL assembly.
Natty Gur[MVP]
blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)52-8888377
*** Sent via Devdex http://www.devdex.com ***
Don't just participate in USENET...get rewarded for it! This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: ForHimself Every Man |
last post by:
What's better about Rattlesnakes than Python. I'm sure there's
something. What is it?
This is not a troll. I'm a snake shooping and I want people's
answers. I don't know beans about Rattlesnakes or have an
preconceived ideas about them. I noticed, however, that everyone I
talk to who are aware of Pythons are also afraid of Rattlesnakes. So
it seems that Rattlesnakes have the potential to compete with and
displace Pythons. I'm...
|
by: michael newport |
last post by:
Dear friends of database(s),
After 13 years of Ingres, I am now using Oracle.
But is Oracle technically better than Ingres.
I would be much obliged if anyone could shed some light on the above
question.
It would also be helpful if you could 'please' keep your comments on a
|
by: Faith Dorell |
last post by:
I really don´t like C.You can write better programs in BASIC than in
C, if you don´t like this language.
I don´t understand how C became so popular, although much better
programming languages existed in the 70s or 80s or 90s.
Pascal is much better.
|
by: bazad |
last post by:
Hi,
I am not using C all the time. I have a general understanding of C
and nothing else. The recent reply to use strlcpy and strlcat showed
me that I am not aware of the best and safe techniques. Is there any
place where I could learn more about safer and better C (on FreeBSD)?
Thank you
|
by: monkeydragon |
last post by:
Which is better, using ReadFile/WriteFile or use fstream?
| |
by: Protoman |
last post by:
Which is better for general-purpose programming, C or C++? My friend
says C++, but I'm not sure. Please enlighten me. Thanks!!!!!
|
by: JoeC |
last post by:
I am working on another game project and it is comming along. It is an
improvment over a previous version I wrote. I am trying to write
better programs and often wonder how to get better at programming. I
tend to learn what is useful and gets the job done. I am always
curious if there is some techique I don't know. I read books and study
as well as write programs. My goal is to some day be able to get a job
programming. I have a...
|
by: gavino |
last post by:
why?
|
by: Ryan Liu |
last post by:
Hi,
Is Async I/O (e.g. NetworkStream.Begin/End Read/Write) always better than
synchronous I/O? At least as good?
When I don't concern about easy or difficult to write code, should I always
use Async I/O?
|
by: Pawel_Iks |
last post by:
I've read somewhere that c++ is something more than better c ... then
I talk with my friend and he claimed that c++ is nothing more than
better c ... I tried to explain him that he was wrong but I forgot all
arguments about it. Could someone told something about it?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |