While entering values into the Table, I left few columns in a row are blank, While load it from Gridview to the Textbox, its all storing as "& nbsp;". I dont want this null value "& nbsp;" to be displayed inside开发者_运维知识库 Textboxes, It has to be be empty when i select from Gridview... What i have to do for that?
If you are using DataSource controls, then set ConvertEmptyStringToNull="true"
to your parameters
<InsertParameters>
<asp:ControlParameter ConvertEmptyStringToNull="true" />
</InsertParameters>
OR if you are using parameterized query then it should be like...
if (TextBox1.Text.Trim() = string.Empty)
{
// pass the null value as parameter
//com.Parameters.AddWithValue("@savePath", null);
}
After assigning value to your TextBox from GridView write the following code:
if(textBoxName.Text == "& nbsp;") { textBoxName.Text = Server.HtmlDecode(textBoxName.Text); }
精彩评论