Help please
I have an example class called Person with 2 public properties Firstname
and Lastname, I cant create a textbox on an asp.net form bound to the
Person.Firstnam e property
Can anyone help with the required syntax?
if i do TExtbox1.text = x.firstname it works ok, but I want to edit the
textbox setting the value of x.firstname.
I am after a webcontrol that will edit person class with a button that will
save person class back to the database.
Here is the page code so far :
#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 TextBox1 As System.Web.UI.W ebControls.Text Box
'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
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
Dim x As New person
x.firstname = "fred"
Page.DataBind()
'Textbox2 has a databinding on the text property = Person.firstnam e
End Sub
End Class
Public Class person
Private _firstname
Public Property firstname() As String
Get
Return _firstname
End Get
Set(ByVal Value As String)
_firstname = Value
End Set
End Property
End Class 2 1718
Bharat,
I'm assuming from your explanation that the person instance is out of scope
when page load is complete.
When it becomes a web user control embedded on a page where should oPerson
be declared so that its properties can be set from the control but
accessible from the containing page. I am thinking I want to save oPerson
into session State so that its properties can become available to other
pages in the browser session?
thanks for the clear explanation so far
Colin
"Bharat Biyani" <Bh**********@d iscussions.micr osoft.com> wrote in message
news:A2******** *************** ***********@mic rosoft.com... Hi Colin,
Follow these steps: 1) Declare a instance of the Person object in your class. YOu are
currently doing it in the method. the instance should be a class member.
2)In aspx file make changes as shown below: <asp:TextBox id="TextBox1" runat="server" Text=<%#p.FName %>/> Here p is the instance name of the Person class declared in the code
behind file.
3) In the PageLoad event binf the textbox to the object y calling the TextBox1.DataBi nd() method.
This will bind the textbox to the object.
--- Bharat Biyani (bs*@orcim.com) http://www.orcim.com "Colin Robinson" wrote:
Help please
I have an example class called Person with 2 public properties
Firstname and Lastname, I cant create a textbox on an asp.net form bound to the Person.Firstnam e property
Can anyone help with the required syntax?
if i do TExtbox1.text = x.firstname it works ok, but I want to edit the textbox setting the value of x.firstname.
I am after a webcontrol that will edit person class with a button that
will save person class back to the database.
Here is the page code so far :
#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 TextBox1 As System.Web.UI.W ebControls.Text Box
'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
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
Dim x As New person
x.firstname = "fred"
Page.DataBind()
'Textbox2 has a databinding on the text property = Person.firstnam e End Sub
End Class
Public Class person
Private _firstname
Public Property firstname() As String
Get
Return _firstname
End Get
Set(ByVal Value As String)
_firstname = Value
End Set
End Property
End Class
Hi,
You can save the Person object in the session. However while creating an
instance of that object it should be done at class level so that it is
available for databinding.
You could do something like this:
Person oPer=(Person)Se ssion[objPerson]; //declare as a class variable.
....
Do databinding
....
//Save changes to person as per the values in the textbox.
Save the person object back to the session.
Session[objPerson]=oPer;
---
Bharat Biyani (bs*@orcim.com) http://www.orcim.com
"Colin Robinson" wrote: Bharat,
I'm assuming from your explanation that the person instance is out of scope when page load is complete.
When it becomes a web user control embedded on a page where should oPerson be declared so that its properties can be set from the control but accessible from the containing page. I am thinking I want to save oPerson into session State so that its properties can become available to other pages in the browser session?
thanks for the clear explanation so far
Colin
"Bharat Biyani" <Bh**********@d iscussions.micr osoft.com> wrote in message news:A2******** *************** ***********@mic rosoft.com... Hi Colin,
Follow these steps: 1) Declare a instance of the Person object in your class. YOu are currently doing it in the method. the instance should be a class member.
2)In aspx file make changes as shown below: <asp:TextBox id="TextBox1" runat="server" Text=<%#p.FName %>/> Here p is the instance name of the Person class declared in the code behind file.
3) In the PageLoad event binf the textbox to the object y calling the TextBox1.DataBi nd() method.
This will bind the textbox to the object.
--- Bharat Biyani (bs*@orcim.com) http://www.orcim.com "Colin Robinson" wrote:
Help please
I have an example class called Person with 2 public properties Firstname and Lastname, I cant create a textbox on an asp.net form bound to the Person.Firstnam e property
Can anyone help with the required syntax?
if i do TExtbox1.text = x.firstname it works ok, but I want to edit the textbox setting the value of x.firstname.
I am after a webcontrol that will edit person class with a button that will save person class back to the database.
Here is the page code so far :
#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 TextBox1 As System.Web.UI.W ebControls.Text Box
'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
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
Dim x As New person
x.firstname = "fred"
Page.DataBind()
'Textbox2 has a databinding on the text property = Person.firstnam e End Sub
End Class
Public Class person
Private _firstname
Public Property firstname() As String
Get
Return _firstname
End Get
Set(ByVal Value As String)
_firstname = Value
End Set
End Property
End Class
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: DraguVaso |
last post by:
Hi,
I'm having the following situation:
- A class clsFournisseur with public property's which raise a
MyPropertyChanged-event in the Set-method for each Property.
Public Event NomChanged As EventHandler
Public Property Nom() As String
Get
Return m_strNom
|
by: Gary Shell |
last post by:
I have a pair of combo boxes on a form. Both have their SelectedValue
property bound to a column on a table called "Input_Output". One column is
called "Class" and the second is called "SubClass". Each combobox has its
datasource, displaymember and SelectedValue member bound to separate tables
thru individual datatsets thru individual data adapters. The two tables are
"Class" and "SubClass".
I use parameterized query to populate the...
|
by: GaryDean |
last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much
in answers so I'm reposting some questions posted by some of the programmers
here in our organization that never got answered...
In 1.1 we always did our own myDataAdapter.fills and we liked that control
for lots of good reasons. Now the new DataSource (or is it a
TableAdapter:Dataset) automatically fills the Gridview. How can we control
that fill?
In a...
|
by: Mark R. Dawson |
last post by:
Hi all,
I may be missing something with how databinding works but I have bound a
datasource to a control and everything is great, the control updates to
reflect the state of my datasource when I update the datasource - awesome,
but I have an issue with updating from a different thread.
Here is my datasource, a person class that raises the PropertyChanged event:
class Person : INotifyPropertyChanged
{
|
by: optictygre |
last post by:
Databinding with reflection
I have a class, SmartString:
Public Class SmartString
...Psuedo code follows
Public Property Value() as String
Return Me.Text
| |
by: Dirk |
last post by:
Hello,
I have a problem to use databinding with my business layer classes. My
data class does not have simple properties (string, int or datetime),
instead, all my properties are objects of the generic type Field<T>
(see sample code).
public class Employee
{
public Field<stringForename
|
by: Brian Pelton |
last post by:
I am trying to bind a textbox to the property of a property.
This code works when nested property is not null,
but it fails when nested is null.
(It fails when SiteLine.Site is null.)
The error is ArgumentNullException: component.
I setup the binding in the constructor of my Form.
|
by: Dustin Davis |
last post by:
I've been having problems with databinding. I've created a simple
solution to emulate the problem I can't figure out. Basically, I have a
TextBox bound to a property in an object. When the property is updated,
how do I get the field to show the new value. I assumed that databinding
would take care of it automatically.
Here is my source code. Can someone tell me what I would need to do to
get TextBox2 to update after the f.value is...
|
by: cmrchs |
last post by:
Hi,
I'm trying out Databinding to a Data Acces Layer using a GridView and
ObjectDataSource-control
The Update works fine but the Delete-method doesn't ???
<asp:GridView ID="GridView1" runat="server"
DataSourceID="ObjectDataSource1"
OnRowUpdating="GridView1_RowUpdating"
|
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: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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
| |