473,324 Members | 2,002 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,324 software developers and data experts.

Clean up

Thanks to S. Justin Gengo, MCP, I think I have a viable editing senario that
would enable searching etc. The general flow goes like this:
Start on a search screen. Select a record. Edit page is displayed. On
save or cancel the user is returned to the search screen. I'm doing this by
creating two user controls (Search and Edit) and placing them in a multiview
with two views. I've got it working but there's a few things that don't seem
very clean to me and was wondering if there's a better .net ish way to do
this.

The page that holds the views:
Partial Class _Default
Inherits System.Web.UI.Page

Protected Sub Search1_Selected(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Search1.Selected
Edit2.RecordId = Search1.RecordId
Edit2.Edit()
MultiView1.ActiveViewIndex = 1
End Sub

Protected Sub Edit2_Finished(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Edit2.Finished
Search1.Refresh()
MultiView1.ActiveViewIndex = 0
End Sub
End Class
The page that searches:
Partial Class Search
Inherits System.Web.UI.UserControl
Dim _recordId As Integer
Public ReadOnly Property RecordId() As Integer
Get
Return _recordId
End Get
End Property
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal
e As System.EventArgs) Handles GridView1.SelectedIndexChanged
Dim row As GridViewRow = GridView1.SelectedRow
_recordId = CInt(row.Cells(1).Text)
RaiseEvent Selected(Me, New EventArgs)
End Sub
Public Event Selected As EventHandler
Public Sub Refresh()
GridView1.DataBind()
End Sub
End Class
The page that edits
Partial Class Edit
Inherits System.Web.UI.UserControl
Public Property RecordId() As Integer
'How do I not use an extra textbox that's hidden?
Get
If IsNumeric(TextBox6.Text) Then
Return CInt(TextBox6.Text)
Else
Return 0
End If
End Get
Set(ByVal value As Integer)
' Special textbox just for the primary key
TextBox6.Text = CStr(value)
SqlDataSource1.DataBind()
End Set
End Property
Public Sub Edit()
Me.DetailsView1.ChangeMode(DetailsViewMode.Edit)
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
'Update, how do I know if there was an error and not raise the event?
DetailsView1.UpdateItem(True)
RaiseEvent Finished(Me, New EventArgs)
End Sub
Public Event Finished As EventHandler

Protected Sub Button2_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
RaiseEvent Finished(Me, New EventArgs)
End Sub
End Class
Any thoughts on cleaning this up a bit and making the search screen control
drive the edit control better are appreciated.
Feb 27 '06 #1
0 953

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

Similar topics

8
by: Craig Thomson | last post by:
I was wondering what people do with text provided by the user in a form. Some cleaning needs to be done at some stage if you are going to be putting it in a database or displaying it etc. But when...
17
by: Christopher Benson-Manica | last post by:
Yesterday I changed some code to use std::vectors and std::strings instead of character arrays. My boss asked me today why I did it, and I said that the code looks cleaner this way. He countered...
10
by: lallous | last post by:
Hello, This question was asked in comp.lang.c++ and the answers involved the use of objects whose destructors are automatically called when getting out of scope, however I was expecting...
5
by: Rob R. Ainscough | last post by:
I have a moderately sized web application (30 pages, and 20 DLLs) that takes 10-20 minutes to "Build Solution" after I do a "Clean Solution" -- this is ONLY apparent after a "Clean Solution" I...
3
by: Nick Gilbert | last post by:
Hi, In my VS.NET 2005, if I choose Build Clean Solution, the BIN folder is not touched. Shouldn't it delete all the dll and pdb files in that folder first? Instead, I'm finding I have to do it...
25
by: Koliber (js) | last post by:
sorry for my not perfect english i am really f&*ckin angry in this common pattern about dispose: ////////////////////////////////////////////////////////// Public class...
0
by: Christopher | last post by:
How can I make a vc++ project erase its $(OutDir) upon using the clean command? I tryed Properties->Configuration Properties->General->Extensions to Delete on Clean Add $(ObjDir) And it...
0
by: service0031 | last post by:
Housekeeping is an interesting job or career where things are always changing, and even though you may work in a less than clean environment, you are required to always look clean and professional....
8
by: plenty900 | last post by:
Hello, I'm trying to build a large project, and I've found that when something doesn't compile properly, and I attempt to re-build it, Visual C++ Express doesn't make a new attempt. So then I...
10
by: Simon | last post by:
As title. How to clean out VSWebCache? Any good way to do that? Thanks.
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: 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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.