Tech
Forums
Jobs
Books
Events
Videos
Conference
Annual Conference
Bcrypt
Ai Conference
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
3
Reply
How to remove columns after particular columns in datatable
Ask a question
Ask a question
Upload Source Code:
Select only zip and rar file.
Raja
7y
301
1
Reply
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>
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
got error while debugging
Doubts on Static method