views:

70

answers:

1

Hello,

I am using grid view and item template text box in ASP.NET USING C#. I am entering text in one line and using entered key again entered text in second line.

BUt after updating i am getting out put data in one line(I used 50 char length in one line.).

Ex.

My first line text. THIS IS TEST JAN 13TH.

second line code

Hello ravi

After updating i am getting like

THIS IS TEST JAN 13TH. Hello ravi

This is my current code i am using.

private CommandArg GetUpdateCommentArgs(int rowIndex) { var retVal = new CommandArg { ObjectParamCollection = new Dictionary() };

        var commentTxt = new string[] { };
        object val = null;

        var cmtTb = GridView1.Rows[rowIndex].FindControl("txtComments") as TextBox;
        if (cmtTb != null)
        {
            cmtTb.Text = cmtTb.Text.Replace("\r\n", " ");
            var los = cmtTb.Text.Length;
            if (los > 100) cmtTb.Text = cmtTb.Text.Substring(0, 100);
            commentTxt =  los > 50
                             ? new[] {cmtTb.Text.Substring(0, 50), cmtTb.Text.Substring(50)}
                             : new[] {cmtTb.Text};

        }
        var key = GridView1.DataKeys[rowIndex];
        if (key != null)
            val = key.Value;

        if (Page is ClaimBase)
        {
            var p = Page as ClaimBase;
            var ci = p.ClaimantInfoHelper;

            if (ci != null)
            {
                if (val != null)
                {
                    var seq = 0;
                    if (Int32.TryParse(val.ToString(), out seq))
                    {
                        var cmtInput = new CommentUpdateInputEntity
                        {
                            ClaimNumber = ci.ClaimNum
                            , CertificateSequence = ci.ClaimCertSeqNo
                            , Sequence = seq
                            , CommentText1 = commentTxt[0]

                        };

                        if (commentTxt.Length > 1)
                            cmtInput.CommentText2 = commentTxt[1];


                        retVal.ObjectParamCollection.Add("entity", cmtInput);
                    }
                }
            }
        }


        return retVal;
    }
A: 

I'm not sure I'm reading what you're asking correctly, but it looks like you just need to replace this line

 cmtTb.Text = cmtTb.Text.Replace("\r\n", " "); 

with this one

 cmtTb.Text = cmtTb.Text.Replace("\r\n", "<br />"); 
Joel Etherton