Click here to Skip to main content
12,624,121 members (33,416 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
System.Data.DataTable db = GetExcelData(path, oSheet.Name);
                foreach (DataColumn item in db.Columns)
                {
                    string Value = db.Rows[0]["Year"].ToString();
                    columnNames.Add(item.ColumnName);
                }
i have problem when i use filter row in datatable the column name contain extra value like (_x0020_) how can avoid this problem even the columns contain one word and no space...
when I check the result in the xml its showing the year like <year_x0020_>1427<year_x0020_>

so how can I find this value in the Year column

Best regard
Posted 8-Jan-13 0:20am
Updated 8-Jan-13 3:51am
v3
Comments
OriginalGriff 8-Jan-13 5:22am
   
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Perhaps the code fragment which sets the filter would help?
Use the "Improve question" widget to edit your question and provide better information.
   
Hi please share the little code so that we can understand your code and requirements. May be you can solve it by using type conversion. First convert it to ToString() and then again to your desired type.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

dataView.RowFilter = "empid = 8";
 
Other examples are
dataView.RowFilter = "EmpName = 'Pankaj'" ;
dataView.RowFilter = "Date = #12/08/2000#" ;
 
Comparision
dataView.RowFilter = "Date>=" + "#" + startdate + "#" +
"And Date <=" + "#" + enddate + "#";
You can find other examples at:
http://www.csharp-examples.net/dataview-rowfilter/
  Permalink  
Comments
Member 8194711 9-Jan-13 0:39am
   
i tried all the examples not working fine.
when i want to discover what is the error i found <year><year> tag its come like this <year_x0020_><year_x0020_> so how can i found the Year column in this <year_x0020_><year_x0020_>
Member 8194711 9-Jan-13 0:54am
   
the main problem i cannot find the column because is has some extra signals i dont know how its came and how can i find the column with this extra signal
<year><year> <year_x0020_><year_x0020_>
jibesh 9-Jan-13 2:22am
   
was the DataTable Columns AutoGenerated ? please post the sample code of how you prepare the DataColumn inside the GetExcelData method
Member 8194711 9-Jan-13 2:26am
   
protected System.Data.DataTable GetExcelData(string ExcelFilePath, string sheetName)
{

string OledbConnectionString = string.Empty;
OleDbConnection objConn = null;
OledbConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ExcelFilePath + ";Extended Properties=Excel 8.0;";
objConn = new OleDbConnection(OledbConnectionString);

if (objConn.State == ConnectionState.Closed)
{
objConn.Open();
}

OleDbCommand objCmdSelect = new OleDbCommand("Select * from [" + sheetName + "$]", objConn);
OleDbDataAdapter objAdapter = new OleDbDataAdapter();
objAdapter.SelectCommand = objCmdSelect;
DataSet objDataset = new DataSet();
objAdapter.Fill(objDataset, "ExcelDataTable");
objConn.Close();
return objDataset.Tables[0];
}
askkk 11-Apr-13 6:10am
   
why?

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100