|
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
|
|
|
|
|
It seems the error is coming from somewhere else where you cast that string to the decimal type. Is that all your sample code? If so, can you also post the stack error?
|
|
|
|
|
You are correct. I was trying to retrieve the value from the cboTitle.DataValueField instead of decTitleID = CDec(cboTitle.SelectedValue)
I get the record ID number this way.
Thank you,
Quecumber256
|
|
|
|
|
Hi, I have a 2 textboxes .. one for the username and one for the password. Now when i try to login, i enter the username then the password and then when i press the ENTER key i wish that the button (Login) will be clicked. But right now when i wrote the user and pass and press the enter key it does not make anything
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
Go to the login form and set the AcceptButton property to be the ID of your Login button. You can also set the CancelButton if your login form has one.
|
|
|
|
|
hi, i am using asp.net .. i cannot see any acceptbuttons in the property .. can you help me please
Adrian De Battista: .Net Programmer, Java Programmer and Web Designer.
|
|
|
|
|
Confirm whether UseSubmitBehaviour of the button is set to True
|
|
|
|
|
hi all,
i have a list of pictures and i want to display all on one page. please give me some idea how to do this.
|
|
|
|
|
Use a repeater or datalist control
only two letters away from being an asset
|
|
|
|
|
I need to return on the page from which I had navigated to the current page.in some conditions the page i have to return is the third or fourth previous page. is their any code to remember the sequance of pages.
I need it plz
With Thanks & Regards
Amit Sk Sharma
|
|
|
|
|
Use a generic list object, adding each new page to it, and then storing it in the session object. You can then iterate down the list seeing all the pages visited to get to the current page.
Regards
Angel
*********************************************
|
|
|
|
|
No need to maintain a collection, one is alreay present. History
only two letters away from being an asset
|
|
|
|
|
Use the Javascript history object in the browser.
history.back(1) or history.back(3)
only two letters away from being an asset
|
|
|
|
|
Hi,
I have written a loop which iterates through all the directories and gives a list of files whose filenames contain a specific search word that has been specified by the user on GUI.
Now I need to display this file list with a hyperlink for each item, so that user can directly click that link and the file associated with that item will open.
How do I do that ?
Pls guide me
Thanks and best regards
Omkar Ghaisas
|
|
|
|
|
How about iterating through the array and creating hyperlinks for each file? One thing to consider is the files are going to be on the server, the user is on a client machine. The list might have drive letters in the path, ie c:\\myshare\\myfile.txt whereas the user would really want to see these as \\server\myshare\myfile.txt .
<br />
<br />
Array<string> mylistofFiles<br />
<br />
<br />
foreach( string myFile in mylistofFiles )<br />
{<br />
HyperLink lnk = new HyperLink();<br />
lnk.Text = "Click to view " + myFile;<br />
lnk.NavigateUrl = myFile;<br />
yourForm.Controls.Add( lnk );<br />
}<br />
This is from memory, and really a 'concept', not a concrete solution. If the file extension is registered on the users system, the correct app will open it for viewing.
Regards
Angel
*********************************************
|
|
|
|
|
Hi,
Thanks for replying. I tried using the above mentioned solution. Worked perfectly fine as far as creating the Hyperlnk is concerned. But the problem here is that when I click on the hyperlink, nothing happens.
What should I do for that.
Thanks a lot for responding quickly.
Best regards
Omkar
|
|
|
|
|
Handle the event and open the file that was clicked.
only two letters away from being an asset
|
|
|
|
|
Can U elaborate a little using some code.. Didn't get you. How do you handle an event of a control that you are generating dynamically ??
Pls clarify.
Thanks and best regards
Omkar Ghaisas
|
|
|
|
|
Control.Event += new EventHandler( MyEventHandler )
only two letters away from being an asset
|
|
|
|
|
i have a requirement like this. i have a wizard control in that i have taken 10 steps, what i have is in step3 i place a radiobutton with yes or no options. when i click yes then i have to activate the next button else i need to deactive the button. how to do this task please help its very urgent.
thank you in advance
praveen kumar reddy
|
|
|
|
|
Here, you might use javascript to enable/disable the Next button, you can do that by registering your script with the client side onclick event of the radiobutton.
|
|
|
|
|
Hi,
I have a datagrid That Updates, it contains many names so I
created a textBox and Button on the webform that if the user wants to edit he should Writes the name in the textbox and on the pressing button the Row is selected automatically and the editing process can be done. Is this possible and if so can some one help me out and tell me how to go about it?
Thanks
|
|
|
|
|
You can hook the Click event of the datagrid control at the server side, and try to access the selected row of the control to edit.
Also, the title is "Search Button", but what you said is all about updating.
|
|
|
|
|
Thanks a lot,
What I was trying to say is that The datagrid updates very well, the text box and button I created them separetly not on the datagrid so that when the user writes the id the row that corresponds with the id in the textbox would be selected. I tryed this but it's not working do you think I'm on the write truck.
private void bttok_click(object sender, System.EventArgs e)
{
SqlCommand myCommand = new SqlCommand("select * from employee where txtname.text=id",con);
SqlDataAdapter myAdapter=new SqlDataAdapter(myCommand);
DataSet ds = new DataSet();
myAdapter.Fill(ds);
con.Open();
myCommand.ExecuteNonQuery();
datagrid1.DataSource=ds;
datagrid1.DataBind();
con.Close();
}
Thanks.
|
|
|
|
|
Hi,
I am trying to store a record. It is saying that the form is invalid. I have several field validators. I would like to know if there is something i can type in the debugging tool to find out exactly which validator it is. Is there an easy way to do this, or do i have to go through ALL my validators on the page??
Thank you.
|
|
|
|