Click here to Skip to main content
Rate this: bad
good
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 1427
 
so how can I find this value in the Year column
 
Best regard
Posted 7-Jan-13 23:20pm
Edited 8-Jan-13 2:51am
v3
Comments
OriginalGriff at 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 at 9-Jan-13 0:39am
   
i tried all the examples not working fine. when i want to discover what is the error i found tag its come like this so how can i found the Year column in this
Member 8194711 at 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
jibesh at 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 at 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 at 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
Your Filters
Interested
Ignored
     
0 Shai Vashdi 540
1 Tadit Dash 305
2 Sergey Alexandrovich Kryukov 250
3 Peter Leow 190
4 OriginalGriff 148
0 Sergey Alexandrovich Kryukov 9,395
1 OriginalGriff 5,473
2 Peter Leow 4,150
3 Maciej Los 3,540
4 Abhinav S 3,333


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