Click here to Skip to main content
15,895,256 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Working With AJAX Pin
RichardGrimmer4-Jul-06 3:09
RichardGrimmer4-Jul-06 3:09 
AnswerRe: Working With AJAX Pin
Tirthadip30-Jun-06 19:08
Tirthadip30-Jun-06 19:08 
QuestionHow to Restrict Selected Webforms Pin
ravindradonkada30-Jun-06 8:07
ravindradonkada30-Jun-06 8:07 
AnswerRe: How to Restrict Selected Webforms Pin
minhpc_bk30-Jun-06 17:07
minhpc_bk30-Jun-06 17:07 
QuestionASP.NET Menu is flaky Pin
gantww30-Jun-06 8:03
gantww30-Jun-06 8:03 
AnswerRe: ASP.NET Menu is flaky - now I'm more confused Pin
gantww30-Jun-06 8:17
gantww30-Jun-06 8:17 
GeneralRe: ASP.NET Menu is flaky - now I'm more confused Pin
gantww30-Jun-06 10:11
gantww30-Jun-06 10:11 
QuestionIndex 0 is not non-negative ! Pin
xuzia30-Jun-06 7:44
xuzia30-Jun-06 7:44 
Hello,

I created a webform.aspx with MS visual studio.net 2003.It has a listbox and a textbox.My page loads the listbox with list of name from a table(profile) from the database.when i select a name anomg the one loaded in the listbox, i want it to insert the personalID of the selected name from the same table(Profile) in the database.

After putting the code behind the page and text my web page, it will load the data from the profile table into the listbox successfully but when i select a name from the listbox, it won't insert the corresponding personalID into the textbox.Instead i get an error message that says [B]"Index 0 is not non-negative and below total row".
Please i need some one to help me correct my code.

Here is the code behinde the page:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
If Not Me.IsPostBack Then
Dim SqlConnection1 As New System.Data.SqlClient.SqlConnection
SqlConnection1.ConnectionString = "data source=xuzia;initial catalog=Pinfol;user id=sa"
Dim cmd As New SqlClient.SqlCommand
cmd.CommandText = "SELECT PersonalID, Name FROM Profile"
cmd.CommandType = CommandType.Text
cmd.Connection = SqlConnection1
SqlConnection1.Open()
Dim DS As New DataSet
Dim DA As New SqlClient.SqlDataAdapter
DA.SelectCommand = cmd
DA.Fill(DS, "Profile")
ListBox1.DataSource = DS
ListBox1.DataMember = "Profile"
ListBox1.DataTextField = "Name"
ListBox1.DataValueField = "PersonalID"
ListBox1.DataBind()
SqlConnection1.Close()
End If
End Sub.

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
Dim prodID As Integer
prodID = ListBox1.SelectedIndex
Dim SqlConnection1 As New System.Data.SqlClient.SqlConnection
SqlConnection1.ConnectionString = "data source=xuzia;initial catalog=pinfo;user id=sa"
Dim SqlSelectCommand1 As New System.Data.SqlClient.SqlCommand
Dim cmd As New SqlClient.SqlCommand
cmd.CommandText = "SELECT PersonalID, Name FROM Profile WHERE PersonalID = " & prdID
cmd.CommandType = CommandType.Text
cmd.Connection = SqlConnection1
SqlConnection1.Open()
Dim DS As New DataSet
Dim DA As New SqlClient.SqlDataAdapter
DA.SelectCommand = cmd
DA.Fill(DS, "Profile")
txtID.Text = DataBinder.Eval(DS, "Tables[Profile].DefaultView.[0].PersonalID")
txtID.DataBind()

End Sub

I will appreciate all help.
Ktsis.



AnswerRe: Index 0 is not non-negative ! Pin
Dustin Metzgar30-Jun-06 8:02
Dustin Metzgar30-Jun-06 8:02 
AnswerRe: Index 0 is not non-negative ! Pin
Guffa30-Jun-06 8:04
Guffa30-Jun-06 8:04 
QuestionCalender control using jscript Pin
Arun Hegde30-Jun-06 7:14
Arun Hegde30-Jun-06 7:14 
AnswerRe: Calender control using jscript Pin
minhpc_bk30-Jun-06 17:18
minhpc_bk30-Jun-06 17:18 
QuestionFile download prompt Pin
eggie530-Jun-06 6:15
eggie530-Jun-06 6:15 
AnswerRe: File download prompt Pin
Frank Kerrigan30-Jun-06 6:28
Frank Kerrigan30-Jun-06 6:28 
QuestionCapturing an image of a PDF? Pin
Goalie3530-Jun-06 5:40
Goalie3530-Jun-06 5:40 
AnswerRe: Capturing an image of a PDF? Pin
Frank Kerrigan30-Jun-06 6:24
Frank Kerrigan30-Jun-06 6:24 
QuestionNeed help on bring up a java script pop up box when clicked on LinkButton. Pin
Slow Learner30-Jun-06 4:16
Slow Learner30-Jun-06 4:16 
AnswerRe: Need help on bring up a java script pop up box when clicked on LinkButton. Pin
Paddy Boyd30-Jun-06 4:21
Paddy Boyd30-Jun-06 4:21 
GeneralRe: Need help on bring up a java script pop up box when clicked on LinkButton. Pin
Slow Learner30-Jun-06 4:45
Slow Learner30-Jun-06 4:45 
GeneralRe: Need help on bring up a java script pop up box when clicked on LinkButton. Pin
Paddy Boyd30-Jun-06 4:50
Paddy Boyd30-Jun-06 4:50 
AnswerRe: Need help on bring up a java script pop up box when clicked on LinkButton. [modified] Pin
l0kke30-Jun-06 4:50
l0kke30-Jun-06 4:50 
GeneralRe: Need help on bring up a java script pop up box when clicked on LinkButton. Pin
Slow Learner30-Jun-06 5:10
Slow Learner30-Jun-06 5:10 
GeneralRe: Need help on bring up a java script pop up box when clicked on LinkButton. Pin
Slow Learner30-Jun-06 5:15
Slow Learner30-Jun-06 5:15 
AnswerRe: Need help on bring up a java script pop up box when clicked on LinkButton. Pin
minhpc_bk30-Jun-06 17:29
minhpc_bk30-Jun-06 17:29 
QuestionHow to disable dates in Calender Control. Pin
Muhammad Chitrali30-Jun-06 4:09
Muhammad Chitrali30-Jun-06 4:09 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.