Nirmal KumarC

Nirmal KumarC

  • NA
  • 327
  • 79.6k

how to type 'System.String' to type'System.Data.DataTable'

Sep 12 2014 4:00 AM
  I want This  problem solved:

Unable to cast object of type 'System.String' to type 'System.Data.DataTable'.

View state value Get source code Here:
string message = TxtMsg.Text;
MatchCollection mc = Regex.Matches(message, @"\*");
int limit = Math.Min(mc.Count, replacements.Length) - 1;
for (int i = limit; i >= 0; i--)
{
message = message.Remove(mc[i].Index, 1).Insert(mc[i].Index, replacements[i]);
}
TxtMsg.Text = message.ToString();
ViewState["Message"] = message.ToString();--> here i am get Viewsate data
 
 
 
My source code:
This source how to convert viewstate value convert System.String' to type 'System.Data.DataTable'.
 
if (ViewState["Message"] != null)
{
DataTable objDt = new DataTable();
objDt = (DataTable)ViewState["Message"];
for (int i = 0; i < objDt.Rows.Count; i++)
{
}
Thanks
 
 
 
 

Answers (1)