开发者

How to display the Null values coming from the Table as blank in Textbox while load from the Gridview?

开发者 https://www.devze.com 2023-03-12 04:28 出处:网络
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;\".

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);
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号