How to maintain Line feeds when saving data to a database
Save the data entered in the multiline textbox as VB.NET .. cmd.Parameters.Add(new SqlParameter(‘@Notes’ ,SqlDbType.NVarChar )) cmd.Parameters (‘@Notes’).Value ='<pre>’ + TextBox1.Text + ‘</pre>’ …. cn.Open() cmd.ExecuteNonQuery() C# … cmd.Parameters.Add(new SqlParameter(‘@Notes’ ,SqlDbType.NVarChar )); cmd.Parameters [‘@Notes’].Value ='<pre>’ + TextBox1.Text + ‘</pre>’; …. cn.Open(); cmd.ExecuteNonQuery(); To retrieve the Data VB.NET Response.Write (ds.Tables(0).Rows(0)(‘Notes’).ToString ()) C# Response.Write (ds.Tables[0].Rows[0][‘Notes’].ToString ());
What is the significance of CommandBehavior.CloseConnection
To avoid having to explicitly close the connection associated with the command used to create either a SqlDataReader or and OleDbDataReader, pass the CommandBehavior.CloseConnection argument to the ExecuteReader method of the Connection. i.e VB.NET dr= cmd.ExecuteReader(CommandBehavior.CloseConnection) C# dr= cmd.ExecuteReader(CommandBehavior.CloseConnection); The associated connection will be closed automatically when the Close method of the Datareader is called. This makes it all the more important to always remember to call Close on your datareaders.
How can I display a Tool tip for a dropdownlist
The ToolTip property is inherited from the WebControl class and is not applicable to the DropDownList control. This implementation of the ToolTip property does not allow you to set a value and returns String. In a word, if we can make this (a dropdown with ToolTip) work with plain HTML and client side script, we should be able to emit the necessary code from ASP.NET. More Details at DropDownList.ToolTip Property
Can I use a dropdownlist to allow user to select multiple items from a list of available items
No. Dropdownlist Web Control allows user to select only one item from a list of items.
I have a page with a Dropdownlist and some simple code for the SelectedIndexChanged but it does not do a postback
If you want the dropdownlist to cause a postback when selection changes set AutoPostBack property to ‘True’ for the dropdownlist control.