Click here to Skip to main content
15,886,077 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In the following code in the if function codes work for save if it does not find any data view. It it finds any dataviews then it goes to else portion and edit the data. But the problem is that when I want to see the text for remarks it shows " ". How can I get it empty value. I mean the txtRemark does not show any data.
C#
private void SaveDataFotblMaintenancePlanDate()
    {
        DataTable DTLocal = null;
        DataView DVLocal = null;
        DataRow DRLocal = null;
        System.Web.UI.Page this_page_ref = null;
        string strSQL = null;

        try
        {
            DTLocal = new DataTable();
            DVLocal = new DataView();
            for (int i = 0; i < grdEdit.Rows.Count; i++)
            {
                //strSQL = "Select * from tblMaintenancePlanDate where MPDCode = '" + txtMPDCode.Text.Trim() + "'";
                strSQL = "Select * from tblMaintenancePlanDate where MPCode = '" + txtMPCode.Text.Trim() + "'";

                ConManager.DBConnection("TERMSMNT");
                ConManager.OpenDataTableThroughAdapter(strSQL, out DTLocal, true);
                DTLocal.TableName = "MaintenanceDates";
                DVLocal.Table = DTLocal;

                if (DVLocal.Count == 0)
                {

                    NewMPDateCode();
                    DRLocal = DTLocal.NewRow();
                    DRLocal["MPDCode"] = txtMPDCode.Text.Trim();
                    DRLocal["SheduleDate"] = Convert.ToDateTime(grdEdit.Rows[i].Cells[1].Text);

                    DRLocal["MPCode"] = Session["USER"].ToString().Trim();
                    DRLocal["Remarks"] = "";


                    DTLocal.Rows.Add(DRLocal);

                    txtMPDCode.Text = "";
                }
                else
                {
                    DRLocal = DVLocal[0].Row;
                    DRLocal.BeginEdit();

                    if (txtSheduleDate.Text != "")
                        DRLocal["SheduleDate"] = Convert.ToDateTime(txtSheduleDate.Text.Trim());
                    if (txtRemark.Text != "")
                        DRLocal["Remarks"] = txtRemark.Text.Trim();
                    if (txtMPDCode.Text != "")
                        DRLocal["MPDCode"] = txtMaintenanceSheduleCode.Text.Trim();
                    DRLocal["MPCode"] = txtMPCode.Text.Trim();

                    DRLocal.EndEdit();

                }
                ConManager.DBConnection("TERMSMNT");
                ConManager.BeginTransaction();
                ConManager.SaveDataTableThroughAdapter(ref DTLocal, true);
                ConManager.CommitTransaction();
            }




        }
        catch (Exception ex)
        {
            throw ex;
        }
        finally
        {
            ConManager.CloseConnection();
        }
    }
Posted
Updated 3-Jun-13 3:08am
v9
Comments
E.F. Nijboer 3-Jun-13 7:20am    
you mean "&nbsp;"?
Sumon562 3-Jun-13 7:30am    
yes
Is your problem solved?
Sumon562 5-Jun-13 2:12am    
Yes, I have solved the problem.
How did you solve it?

1 solution

Please use
C#
string str = Server.HtmlDecode(txtRemark.Text); 
 //OR
string str = Server.HtmlEncode(txtRemark.Text); 
Thanks
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900