I have bind a dataset, DentistDataSet1 , to TextBox, txtLastName, by set the
textbox property (databindings--> simple binding--> ... -->LastName) and also
bind it to a dropdown list, DropdownList1 with datasource (DentistDataSet 1),
DataMember (Dentists), and DataTextField (DentistID), and AutoPostBack(tr ue).
The settings are done by Visual .NET studio 2003.
Also I have the following event code and expect the FirstName and LastName
would be changed with selecting another DentistID in the dropdown list.
-------
Private Sub DropDownList1_S electedIndexCha nged(ByVal sender As
System.Object, ByVal e As System.EventArg s) Handles
DropDownList1.S electedIndexCha nged
txtLastName.Tex t =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName")
txtFirstName.Te xt =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" )
End Sub
------
When I select a new DentistID, I got the following error:
------
Exception Details: System.IndexOut OfRangeExceptio n: There is no row at
position 1.
Source Error:
Line 182: 'txtLastName.Da taBind()
Line 183: 'txtFirstName.D ataBind()
Line 184: txtLastName.Tex t =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName")
Line 185: txtFirstName.Te xt =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" )
Line 186:
------
Any one could help me to figure out the problem? Or what is the correct
steps to set up the properties and coding to get my expected result?
Thank you very much
David 3 1726
You have to refill your dataset on postback...it doesn't magically preserve
its values...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussi ons.microsoft.c om> wrote in message
news:57******** *************** ***********@mic rosoft.com... I have bind a dataset, DentistDataSet1 , to TextBox, txtLastName, by set
the textbox property (databindings--> simple binding--> ... -->LastName) and
also bind it to a dropdown list, DropdownList1 with datasource
(DentistDataSet 1), DataMember (Dentists), and DataTextField (DentistID), and
AutoPostBack(tr ue). The settings are done by Visual .NET studio 2003.
Also I have the following event code and expect the FirstName and LastName would be changed with selecting another DentistID in the dropdown list. ------- Private Sub DropDownList1_S electedIndexCha nged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles DropDownList1.S electedIndexCha nged
txtLastName.Tex t = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName") txtFirstName.Te xt = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" )
End Sub ------
When I select a new DentistID, I got the following error: ------ Exception Details: System.IndexOut OfRangeExceptio n: There is no row at position 1.
Source Error:
Line 182: 'txtLastName.Da taBind() Line 183: 'txtFirstName.D ataBind() Line 184: txtLastName.Tex t = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName") Line 185: txtFirstName.Te xt = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" ) Line 186: ------ Any one could help me to figure out the problem? Or what is the correct steps to set up the properties and coding to get my expected result?
Thank you very much
David
Thank you, Karl:
I have added code to Page_load as follows, but I still got error.
-----------------
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
SqlDataAdapter1 .Fill(DentistDa taSet1)
DropDownList1.D ataBind()
txtLastName.Dat aBind()
txtFirstName.Da taBind()
txtLastName.Tex t =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName")
txtFirstName.Te xt =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" )
End If
SqlDataAdapter1 .Fill(DentistDa taSet1)
'DropDownList1. DataBind()
txtLastName.Tex t =
CStr(DentistDat aSet1.Tables(0) .Rows(CInt(lblC urrentIndex.Tex t))("LastName") )
txtFirstName.Te xt =
CStr(DentistDat aSet1.Tables(0) .Rows(CInt(lblC urrentIndex.Tex t))("FirstName" ))
End Sub
----------------------
Exception Details: System.FormatEx ception: Input string was not in a correct
format.
Source Error:
Line 178: SqlDataAdapter1 .Fill(DentistDa taSet1)
Line 179: 'DropDownList1. DataBind()
Line 180: txtLastName.Tex t =
CStr(DentistDat aSet1.Tables(0) .Rows(CInt(lblC urrentIndex.Tex t))("LastName") )
Line 181: txtFirstName.Te xt =
CStr(DentistDat aSet1.Tables(0) .Rows(CInt(lblC urrentIndex.Tex t))("FirstName" ))
Line 182:
-------------------------
"Karl Seguin" wrote: You have to refill your dataset on postback...it doesn't magically preserve its values...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!)
"david" <da***@discussi ons.microsoft.c om> wrote in message news:57******** *************** ***********@mic rosoft.com... I have bind a dataset, DentistDataSet1 , to TextBox, txtLastName, by set the textbox property (databindings--> simple binding--> ... -->LastName) and also bind it to a dropdown list, DropdownList1 with datasource (DentistDataSet 1), DataMember (Dentists), and DataTextField (DentistID), and AutoPostBack(tr ue). The settings are done by Visual .NET studio 2003.
Also I have the following event code and expect the FirstName and LastName would be changed with selecting another DentistID in the dropdown list. ------- Private Sub DropDownList1_S electedIndexCha nged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles DropDownList1.S electedIndexCha nged
txtLastName.Tex t = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName") txtFirstName.Te xt = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" )
End Sub ------
When I select a new DentistID, I got the following error: ------ Exception Details: System.IndexOut OfRangeExceptio n: There is no row at position 1.
Source Error:
Line 182: 'txtLastName.Da taBind() Line 183: 'txtFirstName.D ataBind() Line 184: txtLastName.Tex t = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName") Line 185: txtFirstName.Te xt = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" ) Line 186: ------ Any one could help me to figure out the problem? Or what is the correct steps to set up the properties and coding to get my expected result?
Thank you very much
David
My guess is that lblCurrentIndex .Text isn't an int like you think it is...
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"david" <da***@discussi ons.microsoft.c om> wrote in message
news:87******** *************** ***********@mic rosoft.com... Thank you, Karl: I have added code to Page_load as follows, but I still got error. ----------------- 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 SqlDataAdapter1 .Fill(DentistDa taSet1) DropDownList1.D ataBind() txtLastName.Dat aBind() txtFirstName.Da taBind() txtLastName.Tex t = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName") txtFirstName.Te xt = DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" ) End If
SqlDataAdapter1 .Fill(DentistDa taSet1) 'DropDownList1. DataBind() txtLastName.Tex t =
CStr(DentistDat aSet1.Tables(0) .Rows(CInt(lblC urrentIndex.Tex t))("LastName") ) txtFirstName.Te xt =
CStr(DentistDat aSet1.Tables(0) .Rows(CInt(lblC urrentIndex.Tex t))("FirstName" )
) End Sub ---------------------- Exception Details: System.FormatEx ception: Input string was not in a
correct format.
Source Error:
Line 178: SqlDataAdapter1 .Fill(DentistDa taSet1) Line 179: 'DropDownList1. DataBind() Line 180: txtLastName.Tex t =
CStr(DentistDat aSet1.Tables(0) .Rows(CInt(lblC urrentIndex.Tex t))("LastName") ) Line 181: txtFirstName.Te xt =
CStr(DentistDat aSet1.Tables(0) .Rows(CInt(lblC urrentIndex.Tex t))("FirstName" )
) Line 182:
-------------------------
"Karl Seguin" wrote:
You have to refill your dataset on postback...it doesn't magically
preserve its values...
Karl
-- MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to come!)
"david" <da***@discussi ons.microsoft.c om> wrote in message news:57******** *************** ***********@mic rosoft.com... I have bind a dataset, DentistDataSet1 , to TextBox, txtLastName, by
set the textbox property (databindings--> simple binding--> ... -->LastName)
and also bind it to a dropdown list, DropdownList1 with datasource (DentistDataSet 1), DataMember (Dentists), and DataTextField (DentistID), and AutoPostBack(tr ue). The settings are done by Visual .NET studio 2003.
Also I have the following event code and expect the FirstName and
LastName would be changed with selecting another DentistID in the dropdown
list. ------- Private Sub DropDownList1_S electedIndexCha nged(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles DropDownList1.S electedIndexCha nged
txtLastName.Tex t =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName") txtFirstName.Te xt =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" ) End Sub ------
When I select a new DentistID, I got the following error: ------ Exception Details: System.IndexOut OfRangeExceptio n: There is no row at position 1.
Source Error:
Line 182: 'txtLastName.Da taBind() Line 183: 'txtFirstName.D ataBind() Line 184: txtLastName.Tex t =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "LastName") Line 185: txtFirstName.Te xt =
DentistDataSet1 .Tables(0).Rows (DropDownList1. SelectedIndex)( "FirstName" ) Line 186: ------ Any one could help me to figure out the problem? Or what is the
correct steps to set up the properties and coding to get my expected result?
Thank you very much
David This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Vijaya |
last post by:
Can we bind data to textbox in a headertemplate in a
template column of a datagrid?
If so please give some code snippets.
Thank you
|
by: Vigneshwar Pilli via DotNetMonster.com |
last post by:
string connectionString1 = "server=(local); user=sa;password=sa;
database=sonic";
System.Data.SqlClient.SqlConnection dbConnection1 = new
System.Data.SqlClient.SqlConnection(connectionString1);
System.Data.SqlClient.SqlCommand dbCommand1 = new
System.Data.SqlClient.SqlCommand();
|
by: Robert Smith jr. |
last post by:
Hello,
Please pardon my newbie question ...
I am building an ASP.NET page that displays a recordset with a Delete
statement enabled (this all works fine). I want to Insert the current
row *that is going to be deleted* into another table, before the
original data is deleted.
I am trying to use the RowDeleting method to call an Update or Insert
|
by: Aspnot |
last post by:
I have a TabControl that is on a form that is bound to a DataSet. I bind the
dataset to the form in the Form_Load event. The TabControl has 2 TabPages.
The first TabPage contains a button and a textbox.
Scenario 1:
I call BindingContext(ds.TableName).AddNew(), then I click the button and
that populates some text into the textbox on the first tab. Then I switch
over to Tab2 and back to Tab1. The text that was programatically inserted...
|
by: sutphinwb |
last post by:
Hi - This could be a simple question. When I relate two tables in a
datasetet, how do I get that relation to show up in a GridView? The
only way I've done it, is to create a separate table in the dataset
with a join query for the GetData() select method. I use
ObjectDataStore to couple the GridView with the table adapter on the
dataset. If I point the ODS at the child table, the GridView will bind
to the "normal" select and I end up...
| |
by: Sam |
last post by:
I am trying to use a Simple form with 3 fields from SQL NorthWind
Database (Order Details Table with 3 Fields. - OrderId, ProductId and
Unit Price). The Field Unit Price has a data type of 'Money Type'.
All I want is to able to edit/view/insert 'UnitPrice' field with 2
decimal points instead of 4 decimal points.
If I use: Bind("UnitPrice", "{0:c}") in Edit Template, I got: "Input
string was not in a correct format...". Although this...
|
by: Sam |
last post by:
Folks..
I am trying to use a Simple form with 3 fields from SQL NorthWind
Database (Order Details Table with 3 Fields. - OrderId, ProductId and
Unit Price). The Field Unit Price has a data type of 'Money Type'.
All I want is to able to edit/view/insert 'UnitPrice' field with 2
decimal points instead of 4 decimal points.
|
by: RolfHerbert |
last post by:
Hi all,
Source code below. I am using an sqldatasorce to populate a datagrid.
I am using datakeyIds.
I am interested in two keys which I have added to the datakeyids,
however if either of the keys is not databound, set to visible=false
or readonly=true, they are unavailable as parameters in my update
statement.
|
by: Cirene |
last post by:
I have a formview that is calling a stored procedure (thru an sqldatasource)
to update 2 tables. When I execute the update it runs fine, with no errors.
But the data does NOT change. Any ideas why?
Here's the stored proc, the datasource and the edit template of the
formview...
***************STORED PROC*******************
ALTER PROCEDURE dbo.UpdateCompanyUsers
(
|
by: John Mason |
last post by:
Hi,
I've been trying for most of the day to get a FormView control to work.
I would like to display a single record, based on a unique user id
(loginid), which I am retreiving from a cookie. No paging involved. I
want to give the user the ability to edit their record and update it (no
insert).
I pre-populate the database fields with values, and when I execute the
page, it wipes out the corresponding database field values belonging to
|
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: 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: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |