Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Lit.Text = ds.Tables[0].Rows[0]["BlogPath"].ToString();
Lit.DataBind();


Dear friends I want to store Lit.Text value in String variable.
So Can I do this?If Yes Then how we can do this.

Thanks in Advance
Akhilesh Pathak
Posted
Comments
[no name] 12-Mar-13 3:27am    
What do you mean by 'Literal Value' here?
Akhilesh Kumar Pathak 12-Mar-13 3:29am    
The value which is in
Lit.Text=ds.Tables[0].Rows[0]["BlogPath"].ToString();
Now I want to do
string name=Lit.Text.ToString();
[no name] 12-Mar-13 3:30am    
so what is stopping you?? If you are getting error paste it with your question. And with Text what you want to use ToString(), Text property returns string only.

1 solution

Try
string s = ds.Tables[0].Rows[0]["BlogPath"].ToString();
 
Share this answer
 
Comments
Akhilesh Kumar Pathak 12-Mar-13 3:31am    
Thank You Abhinav Ji!!
I have tried this But Its not working.
Abhinav S 12-Mar-13 3:45am    
Not working? Are you getting an error?
Akhilesh Kumar Pathak 12-Mar-13 3:49am    
Lit.Text = ds.Tables[0].Rows[0]["BlogPath"].ToString();
Lit.DataBind();

string name = ds.Tables[0].Rows[0]["BlogPath"].ToString();
string filePath = blgFile.PostedFile.FileName;
if (System.IO.File.Exists(Server.MapPath("~/TextFiles/Blogs/") + name))
{
string fileName = Server.MapPath("~/TextFiles/Blogs/") + name;
String contents = File.ReadAllText(fileName);
Mr.Abhinav Ji!This is my code to read recent file uploaded in TextFiles\Blogs folder.
So I am searching recent file in folder But it jump out of If block and not entered in Ifs block.Thats why I am saying its not woking.
I want write files content on Literal control.
Thanks
[no name] 12-Mar-13 4:04am    
Akhilesh Ji! How will saving in literal solve your problem. Add Watch to 'filePath' and see if you are getting correct string.
Abhinav S 12-Mar-13 4:09am    
Looks like you are getting an incorrect filename. Debugging should help!

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