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
diamond diamond
NA
133
55.3k
display of datatable contain issue
Jul 30 2013 10:43 PM
Hi,
I have datatable, I want to display it contain, but it does not work.
void Form1_Load(object sender, EventArgs e)
{
DataClasses1DataContext dc = new DataClasses1DataContext();
var Kelihos = from n in dc.kv1s
select n;
DataTable dt = new DataTable("kelihos");
DataColumn col1 = new DataColumn("saddr", typeof(string));
dt.Columns.Add(col1);
DataColumn col2 = new DataColumn("daddr", typeof(string));
dt.Columns.Add(col2);
DataColumn col3 = new DataColumn("dur", typeof(string));
dt.Columns.Add(col3);
DataColumn col4 = new DataColumn("dport", typeof(string));
dt.Columns.Add(col4);
DataColumn col5 = new DataColumn("state", typeof(string));
dt.Columns.Add(col5);
DataColumn col6 = new DataColumn("proto", typeof(string));
dt.Columns.Add(col6);
DataColumn col7 = new DataColumn("bytes", typeof(string));
dt.Columns.Add(col7);
DataColumn col8 = new DataColumn("pkts", typeof(string));
dt.Columns.Add(col8);
DataColumn col9 = new DataColumn("stime", typeof(string));
dt.Columns.Add(col9);
DataColumn col10 = new DataColumn("ltime", typeof(string));
dt.Columns.Add(col10);
int row = 0;
foreach (var item in Kelihos)
{
dt.Rows.Add();
dt.Rows[row][0] = item.saddr.ToString().Trim();
dt.Rows[row][1] = item.daddr.ToString().Trim();
dt.Rows[row][2] = item.dport.ToString().Trim();
dt.Rows[row][3] = item.dur.ToString().Trim();
dt.Rows[row][4] = item.state.ToString().Trim();
dt.Rows[row][5] = item.proto.ToString().Trim();
dt.Rows[row][6] = item.bytes.ToString().Trim();
dt.Rows[row][7] = item.pkts.ToString().Trim();
dt.Rows[row][8] = item.stime.ToString().Trim();
dt.Rows[row][9] = item.ltime.ToString().Trim();
row++;
}
}
Please help me to write suitable code for print its contain.
Reply
Answers (
7
)
Combobox multiselection search like filter in MS Excell
Web Designing