|
Hi
I have one Generic List how to convert the list into data table?. Any one help me please?.
Regards
Kesavan
kesavan
|
|
|
|
|
AFAIK there is only the long way - loop through the list and add each item
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
I don't really know why you need it. In many cases is better to loop throght the items and execute the query directly.
But:
You can generate a common code that:
Uses Reflection to discover the properties/fields of the classes.
Be able to map the fields to the columns with the same name or, to create such columns in the datatable (that depends on your need).
Then, loop at each item adding a row and loop for each field/property setting the right column value.
|
|
|
|
|
CSLA has/had a class called ObjectAdaptor that was designed to do what you want.
|
|
|
|
|
What type of list?
For list of int you can do it like this:
List<int> myList = new List<int>(100);
for (int i = 1; 1 <= 50; i++)
{
myList.Add(i);
}
DataTable dt = new DataTable("MyTbl");
dt.Columns.Add("MyColumn", Type.GetType("System.Int32"));
for (int j = 0; j < myList.Count; j++)
{
dt.Rows.Add(myList[j]);
}
|
|
|
|
|
Hiiiiiiiiiiiiiiiiiiii allllllll
I need helping of coding how i can chicking the occourance of congestion at net., and implement the congestion avoidance algorithms
|
|
|
|
|
Gooooooooooooooooooooooooooooooooooood!
Whaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaat haaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaave yooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooou triiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiied?
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
I don't understand what do u mean at all................
|
|
|
|
|
what have you tried?
It would help to know what you tried.
People aren't going to write you the code here.
They'll help you figure out where you went wrong once you have done a bonafide attempt, but trying to just ask for what to do is frowned on.
|
|
|
|
|
3bood.ghzawi wrote: congestion
do you mean collision?
try entering some keywords in the Google search box.
|
|
|
|
|
Hi all...........
I'm asking of how i can implement an IPsec. operation using C#...............
With my regards for all............
|
|
|
|
|
I suggest you use your keyboard for entering meaningful questions, not series of periods.
I doubt someone is going to correctly guess what it is you want.
|
|
|
|
|
hi
i am converting onedatabase file into txt file. This file containing some character like squre box and junk character like this
דךח0ח דךח3חדךח2חדךח=חדךח<חדךח?ח
if its a font(problem) or conversion problem
|
|
|
|
|
It depends on what file your are converting, how you are converting, are taking care of encoding and may be many more.
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
in the western world it wouldn't look like a font problem as there isn't a readable word anywhere.
I suggest you ask your local witchdoctor.
without any information about your app, your database, your data types, nobody here will be able to tell you the answer.
|
|
|
|
|
hi all,
I want to know that if I create a toolbar for IE(like google toolbar) or any browser using .net
then it is necessary that .net frmaework is installed on client machine.
Thanks in advance.
|
|
|
|
|
Yes.
Any software created for .NET requires .NET to be installed on the machine it is to run on. V3.0 is installed already on Vista and Weven, ealier version may need to be installed.
All those who believe in psycho kinesis, raise my hand.
|
|
|
|
|
That's not quite true. There are applications, such as Thinstall, which will embed the runtime into a single application which can be run without the .NET framework. They are expensive, and largely unnecessary, but they do work.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Xenocode has a trial out now that works as far as I can tell. I finished a product using it, despite my advisement to the client about the risks and issues with using such a tool.
With .net preinstalled on weven and vista, most XP machines have it too, is it really such a big issue anymore?
|
|
|
|
|
Hi...
In my application, we are used MySql Database.. I m working with C# Windows application . we are using ODBC connectivity with MySql.. We want to take Db Backup from our application. I was tried and achieved in Local machine via get mySQl root path from Registry.. But want to take Backup Remote machine MySql Database also... How can we achieve this... If u have any idea Please Share with me...
Thank you
|
|
|
|
|
Hi,
I have created a web survey control which is working fine, now I have to create same thing for desktop application [Survey control for desktop application].
Please let me know your suggestions.
Can I create a survey type of desktop application in WPF?
I am working in VisualStudio2008 using C#.
Thanks
|
|
|
|
|
Yes you can, in both WPF and WinForms. Why not?
50-50-90 rule: Anytime I have a 50-50 chance of getting something right, there's a 90% probability I'll get it wrong...!!
|
|
|
|
|
Hello all
my problem is that for some reason, a simple assignment isn't working.
the dataGridView is binded to DB and im trying to assign a value type string to a column of type string
bindingSourceSchema.DataSource = null;
dgwSchema.Columns["colID"].DataPropertyName = "APP_ID";
dgwSchema.Columns["colName"].DataPropertyName = "DESCRIPTION";
dgwSchema.Columns["colTextbox"].DataPropertyName = "APP_ARGS";
dgwSchema.Columns["colTextbox"].HeaderText = "Parameters";
dgwSchema.Columns["colLink"].DataPropertyName = "APP_PATH";
dgwSchema.Columns["colLink"].HeaderText = "Path";
DataGridViewLinkColumn colLink = (DataGridViewLinkColumn)dgwSchema.Columns["colLink"];
colLink.UseColumnTextForLinkValue = true;
colLink.Text = "Edit";
bindingSourceSchema.DataSource = SchemaDB.GetGenericApps();
.
.
.
if (openFileDialog.ShowDialog() == DialogResult.OK)
{
dgwSchema.CurrentRow.Cells["colLink"].Value = openFileDialog.FileName;
}
Thanks
Eyal
|
|
|
|
|
The reason is following property is set to true.
colLink.UseColumnTextForLinkValue = true;
Set it to false. Then it will resolve your problem.
|
|
|
|
|
hi....now im doing work on Line count for word documents...1st i hav 2 select Dr name n date n then add files in listview and then if i go for save those files will save in ms word table as separately as Different DR name n Date wise in seperate tables...
....BUT iam getting repeating in one table lik...
Dr.Name:Dr.Jhon
Date:20/12/2009
Sno FileName Count
1 Hobbs.doc 36.31
2 Horn.doc 45.72
3 McMillan.doc 41.49
4 Smith.doc 10.72
Dr.Name:Dr.king
Date:22/12/2009
Sno FileName Count
1 Hobbs.doc 36.31
2 Horn.doc 45.72
3 McMillan.doc 41.49
4 Smith.doc 10.72
..........................................................................
this is actully i want 2 get....
Dr.Name:Dr.Jhon
Date:20/12/2009
Sno FileName Count
1 Hobbs.doc 36.31
2 Horn.doc 45.72
Dr.Name:Dr.king
Date:22/12/2009
Sno FileName Count
1 McMillan.doc 41.49
2 Smith.doc 10.72
Here is my code...
private void btnsave_Click(object sender, EventArgs e)
{
for (int k = 1; k < listView1.Items.Count; k++)
{
if (listView1.Items[k - 1].Text != listView1.Items[k].Text)
{
dte.Add(listView1.Items[k - 1].Text);
dte.Add(listView1.Items[k].Text);
}
if (listView1.Items[k - 1].SubItems[3].Text != listView1.Items[k].SubItems[3].Text)
{
pname.Add(listView1.Items[k - 1].SubItems[3].Text);
pname.Add(listView1.Items[k].SubItems[3].Text);
}
}
object oMissing = System.Reflection.Missing.Value;
object oEndOfDoc = "\\endofdoc"; /* \endofdoc is a predefined bookmark */
Microsoft.Office.Interop.Word._Application oWord;
Microsoft.Office.Interop.Word._Document oDoc;
oWord = new Microsoft.Office.Interop.Word.Application();
oWord.Visible = true;
oDoc = oWord.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);
for (int k = 0; k < dte.Count; k++)
{
Microsoft.Office.Interop.Word.Paragraph oPara1;
oPara1 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara1.Range.Text = pname[k].ToString();
oPara1.Range.Font.Bold = 1;
oPara1.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
oPara1.Range.InsertParagraphAfter();
Microsoft.Office.Interop.Word.Paragraph oPara2;
oPara2 = oDoc.Content.Paragraphs.Add(ref oMissing);
oPara2.Range.Text = "Date:" + dte[k].ToString();
oPara2.Range.Font.Bold = 1;
oPara2.Format.SpaceAfter = 24; //24 pt spacing after paragraph.
oPara2.Range.InsertParagraphAfter();
int a = listView1.Items.Count + 1;
Microsoft.Office.Interop.Word.Table oTable;
Microsoft.Office.Interop.Word.Range wrdRng = oDoc.Bookmarks.get_Item(ref oEndOfDoc).Range;
oTable = oDoc.Tables.Add(wrdRng, a, 3, ref oMissing, ref oMissing);
oTable.Range.ParagraphFormat.SpaceAfter = 6;
oTable.Cell(1, 1).Range.Text = "SNO";
oTable.Cell(1, 2).Range.Text = "FileName";
oTable.Cell(1, 3).Range.Text = "Total Count";
for (int r = 1; r < a; r++)
{
oTable.Cell(r + 1, 1).Range.Text = listView1.Items[r - 1].SubItems[1].Text;
oTable.Cell(r + 1, 2).Range.Text = listView1.Items[r - 1].SubItems[2].Text;
oTable.Cell(r + 1, 3).Range.Text = listView1.Items[r - 1].SubItems[5].Text;
oTable.Rows[r].Height = oWord.InchesToPoints(0);
}
oTable.Columns[1].Width = oWord.InchesToPoints(0); //Change width of columns 1 & 2
oTable.Columns[2].Width = oWord.InchesToPoints(0);
oTable.Columns[3].Width = oWord.InchesToPoints(0);
oTable.Rows[1].Range.Font.Bold = 1;
}
MessageBox.Show("Save Successfully");
}
}
}
plzz...help me ............thanquuu....
|
|
|
|