Click here to Skip to main content
15,907,906 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: debugging in visual web development 2005 express Pin
RichardGrimmer8-Jan-07 7:14
RichardGrimmer8-Jan-07 7:14 
QuestionApplying a CSS attribute to a user control Pin
Tina P8-Jan-07 6:45
Tina P8-Jan-07 6:45 
AnswerRe: Applying a CSS attribute to a user control Pin
Not Active8-Jan-07 7:34
mentorNot Active8-Jan-07 7:34 
GeneralRe: Applying a CSS attribute to a user control Pin
Tina P8-Jan-07 11:14
Tina P8-Jan-07 11:14 
Questionproblem with dropdown list Pin
praveenanand8-Jan-07 5:37
praveenanand8-Jan-07 5:37 
AnswerRe: problem with dropdown list Pin
RichardGrimmer8-Jan-07 7:16
RichardGrimmer8-Jan-07 7:16 
AnswerRe: problem with dropdown list Pin
Not Active8-Jan-07 7:24
mentorNot Active8-Jan-07 7:24 
QuestionDatabinding DataValueField to record ID Pin
Quecumber2568-Jan-07 5:33
Quecumber2568-Jan-07 5:33 
I have the following code:
Protected Sub Page_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Load

Dim strConn As String = MRMFunctions.WebConfigConnString
dsTitles.ConnectionString = strConn
Dim strTitleSQL = "SELECT * FROM tblTitles WHERE [Deleted] = 0;"
dsTitles.SelectCommand = strTitleSQL
cboTitle.DataSourceID = dsTitles.ID.ToString
cboTitle.DataTextField = "Title"
cboTitle.DataValueField = "TitleID"
End Sub

The purpose of this code is to retrieve the connection string from the Web.Config file and place that into a variable called strConn.

Next, I assign the SqlDataSource(dsTitles)control to that connection string.

I retrieve the data I want from the Sql Server Database with the strTitleSQL statement by selecting every field from the tblTitles table where the field named ‘Deleted’ is equal to false. I set the Datasource select command to the strTitleSQL variable.

I am now going to databind the control cboTitle by assigning the DataSourceID equal to the dsTitles datasource ID.

I assign the cboTitle.DataTextField to the Title field from the SQL statement. This is the information that will be placed in the drop down list.

Logically, I should be able to assign the record ID number to the DataVieldValue by assigning the cboTitle.DataValueField to the TitleID field. Instead I am getting the error, “Conversion from string ‘TitleID’ to type Decimal is not valid.”

I understand that it is seeing the string ‘TitleID’ as the string for the DataValueField. What I don’t understand is why is the DataTextField is seeing ‘Title’ as the field name from the SQL statement, but the DataValueField is not seeing ‘TitleID’ as the same?

Thank you,


Quecumber256
AnswerRe: Databinding DataValueField to record ID Pin
minhpc_bk8-Jan-07 8:56
minhpc_bk8-Jan-07 8:56 
GeneralRe: Databinding DataValueField to record ID Pin
Quecumber2568-Jan-07 9:57
Quecumber2568-Jan-07 9:57 
QuestionButton Error Pin
ADY0078-Jan-07 1:57
ADY0078-Jan-07 1:57 
AnswerRe: Button Error Pin
John Gathogo8-Jan-07 2:05
John Gathogo8-Jan-07 2:05 
GeneralRe: Button Error Pin
ADY0078-Jan-07 2:11
ADY0078-Jan-07 2:11 
GeneralRe: Button Error Pin
John Gathogo8-Jan-07 2:53
John Gathogo8-Jan-07 2:53 
Questionkind of thumbnails Pin
NadyaS8-Jan-07 1:46
NadyaS8-Jan-07 1:46 
AnswerRe: kind of thumbnails Pin
Not Active8-Jan-07 2:47
mentorNot Active8-Jan-07 2:47 
Questionhow to return on the same previous page Pin
Amit Sk Sharma8-Jan-07 1:44
Amit Sk Sharma8-Jan-07 1:44 
AnswerRe: how to return on the same previous page Pin
Malcolm Smart8-Jan-07 1:51
Malcolm Smart8-Jan-07 1:51 
GeneralRe: how to return on the same previous page Pin
Not Active8-Jan-07 2:46
mentorNot Active8-Jan-07 2:46 
AnswerRe: how to return on the same previous page Pin
Not Active8-Jan-07 2:45
mentorNot Active8-Jan-07 2:45 
QuestionDisplaying a list of files in a directory with clickable link Pin
Omkar Ghaisas8-Jan-07 1:31
Omkar Ghaisas8-Jan-07 1:31 
AnswerRe: Displaying a list of files in a directory with clickable link Pin
Malcolm Smart8-Jan-07 2:01
Malcolm Smart8-Jan-07 2:01 
GeneralRe: Displaying a list of files in a directory with clickable link Pin
Omkar Ghaisas8-Jan-07 2:27
Omkar Ghaisas8-Jan-07 2:27 
GeneralRe: Displaying a list of files in a directory with clickable link Pin
Not Active8-Jan-07 2:39
mentorNot Active8-Jan-07 2:39 
GeneralRe: Displaying a list of files in a directory with clickable link Pin
Omkar Ghaisas8-Jan-07 2:42
Omkar Ghaisas8-Jan-07 2:42 

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.