TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Raja
NA
2k
355.9k
How to remove columns after particular columns in datatable
Nov 1 2016 1:53 AM
I want to remove columns from data table after particular columns.I have used Remove method but this is delete the '("Lead Time (WEEKS)"))' columns i want to remove after the '("Lead Time (WEEKS)"))' columns.<br /> How to do it<br /><div> I have used below code.</div><div> </div><div> </div><div><pre id="pre889236" style=" 0px;">for (int i = 0; i < ds.Tables.Count; i++) <br /> { <br /> for (int j = 0; j < ds.Tables[i].Columns.Count; j++) <br /> { <br /> if (ds.Tables[i].Rows[7][j].ToString().Trim().Contains("Lead Time (WEEKS)")) <br /> { <br /> int y = j; <br /> if (ds.Tables[i].Rows[7][y + 1].ToString().Trim() == "" || ds.Tables[i].Rows[7][y + 1].ToString().Trim() != "") <br /> { int y1 = y + 1;<br /> ds.Tables[i].Columns.RemoveAt(y1); <br /> } <br /> } <br /> } <br /> }</pre> </div>
Reply
Answers (
3
)
got error while debugging
Doubts on Static method