What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 10628 |  Welcome, Guest!   Register  Login
 Home > Forums > C# > Column Header Problem in DataTable Select Method ...
T.saravanan

Column Header Problem in DataTable Select Method

Replies: 1 | Posted by: T.saravanan on 11/30/2010 | Category: C# Forums | Views: 1996 | Status: [Member] [MVP] | Points: 10  


Hi All,

I am using data filter from DataTable using Select method.In my case Column Header have a special character so in filter section comes error.

Here is my Code...

In this case its working fine..


string sCondition = string.Format("[{0}] = '{1}'", "Country Name", "India");
DataRow[ ] dr = dtData.Select(sCondition);


Problem is occured in this case...

string sCondition = string.Format("[{0}] = '{1}'", "Unit [in Cr]", "INR");
DataRow[ ] dr = dtData.Select(sCondition);


In this case Column Name have brace '[ ] ' so my filter condition is not working..
Exception thrown: "Cannot interpret token ']' at position 11 "
Please any one suggest me how to filter this type of column using Select method.

Advance Thanks.... :(

Thanks,
T.Saravanan


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

T.saravanan
T.saravanan  
Posted on: 11/30/2010 8:22:56 AM
Level: Silver | Status: [Member] [MVP] | Points: 50

Resolved

Hi All,

Thanks for your effort...

Now i am found out the solution..

Just add a slash ("\") in near to closing brace...


string sCondition = string.Format("[{0}] = '{1}'", "Unit [in Cr\]", "INR");
DataRow[ ] dr = dtData.Select(sCondition);


Reference :http://msdn.microsoft.com/en-us/library/system.data.datacolumn.expression%28VS.71%29.aspx

Cheers :)



Thanks,
T.Saravanan

T.saravanan, if this helps please login to Mark As Answer. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 11:39:35 PM