Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Dear Users,
 
I habe an requirement on assigning a new line to String variable from dataset values please find out the suitable solution..Below is my code..
private string ContactDtlsToPDF(GridView grdC)
{
      ds = CntDetailsToPDF();
 
      for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
      {
            Body += ds.Tables[0].Rows[i]["Name"].ToString() + " " + ds.Tables[0].Rows[i]["Mobile"].ToString() + <"br/"> + " ";
      }
 
      return Body;
}
If my dataset has 5 Rows then it var body should hold 5 individual rows i have tried with br tag but not helpful...
Posted 15-Feb-13 19:31pm
sahmed3208
Edited 16-Feb-13 1:21am
v2
Comments
Sergey Alexandrovich Kryukov at 16-Feb-13 1:33am
   
This "code" cannot even compile. Why it's so difficult? I see you put <> brackets outside "", concatenate strings... Come on, learn System.String class and the simplest techniques first. If you help you, you will hardly learn it... —SA
technovate at 16-Feb-13 1:42am
   
the is just a part code snippet i have posted i need any other solution..the above code is compiliong...Body +=ds.Tables[0].Rows[i]["Name"].ToString()+" "+ds.Tables[0].Rows[i]["Mobile"].ToString()+"<br/>";
Sandeep Mewara at 16-Feb-13 1:50am
   
Sounds like a homework where you have not spent much time and have not tried anything.
technovate at 16-Feb-13 1:55am
   
Just go through the code.. private string ContactDtlsToPDF(GridView grdC) { ds = CntDetailsToPDF(); for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { Body +=ds.Tables[0].Rows[i]["Name"].ToString()+" "+ds.Tables[0].Rows[i]["Mobile"].ToString()+"<br/>"; } return Body; } where i've declared Body as a string if i have 3 rows in my dataset all the 3 three rows values are assigning it together...but i need it in a new line..i hope it;s clearn now..
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

I have done with
below code
Str = "<table id="" ctl00_contentplaceholder1_tblstring2="" style="" cellpadding="" 0="" cellspacing=""><tr>"
        Str += "<td id="" ctl00_contentplaceholder1_txtmsg1="" style="" left="">"
        arrLines = Split(TxtMsg.Text, vbCrLf)
        For Each strLine In arrLines
            Str += "</td></tr>" & strLine & "<tr><td>"
        Next
        Str += "</td></tr><tr>"
        Str+="</tr></table>"
May be This Will Help you
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

Please make changes in following code.
private string ContactDtlsToPDF(GridView grdC)
{
      ds = CntDetailsToPDF();
 
      for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
      {
            if(Body == "")
            Body = ds.Tables[0].Rows[i]["Name"].ToString() + " " + ds.Tables[0].Rows[i]["Mobile"].ToString()";
else
Body += Environment.NewLine + ds.Tables[0].Rows[i]["Name"].ToString() + " " + ds.Tables[0].Rows[i]["Mobile"].ToString()";
      }
 
      return Body;
}
  Permalink  

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 710
1 OriginalGriff 543
2 Abhinav S 318
3 thatraja 245
4 Tadit Dash 140
0 Sergey Alexandrovich Kryukov 8,322
1 OriginalGriff 4,790
2 Peter Leow 3,784
3 Maciej Los 3,515
4 Er. Puneet Goel 3,107


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 17 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid