Click here to Skip to main content
15,906,816 members
Home / Discussions / C#
   

C#

 
Questionhow to connect to dbf database Pin
goldsoft28-Aug-11 22:19
goldsoft28-Aug-11 22:19 
AnswerRe: how to connect to dbf database Pin
Wayne Gaylard28-Aug-11 22:28
professionalWayne Gaylard28-Aug-11 22:28 
AnswerRe: how to connect to dbf database Pin
phil.o28-Aug-11 23:28
professionalphil.o28-Aug-11 23:28 
AnswerRe: how to connect to dbf database Pin
Eddy Vluggen29-Aug-11 0:28
professionalEddy Vluggen29-Aug-11 0:28 
AnswerRe: how to connect to dbf database Pin
V.29-Aug-11 3:32
professionalV.29-Aug-11 3:32 
QuestionAsp.net Pin
prabhatkumartiwari28-Aug-11 19:32
prabhatkumartiwari28-Aug-11 19:32 
Question[SPAM, almost] Pin
gsue28-Aug-11 19:06
gsue28-Aug-11 19:06 
QuestionXML File -> DataGridView - One additional row of data Pin
TheBlindWatchmaker28-Aug-11 18:21
TheBlindWatchmaker28-Aug-11 18:21 
Hi all,

I am trying to implement read and write functionality between DataGridViewload controls and an XML file.

The code to write the the XML file is as follows
C#
DataTable dt_csk = new DataTable("CONTROL_KEYS");
dt_csk.Columns.Add("key", typeof(System.String));
dt_csk.Columns.Add("value", typeof(System.String));

for (idx = 0; idx < dgv_csk.Rows.Count; idx++)
{
    dt_csk.Rows.Add(dgv_csk[0, idx].Value.ToString(), dgv_csk[1,  idx].Value.ToString());                    
}

dt_csk.EndLoadData();
dt_csk.AcceptChanges();
dgv_csk.DataSource = dt_csk.DefaultView;


I then add all DataTables to a DataSet like so

C#
DataSet ds = new DataSet();
ds.Tables.Add(dt_csk);
ds.Tables.Add(dt_cdk);
ds.Tables.Add(dt_cak);

/* Output the contents of the DataSet as an XML file */
ds.WriteXml(logfile, XmlWriteMode.IgnoreSchema);


I read the XML into the DataGridView elements as follows:

C#
XmlDataDocument xmldata = new XmlDataDocument();
xmldata.DataSet.ReadXml(xml_filename);


dgv_csk.DataSource = xmldata.DataSet;

dgv_csk.DataMember = "CONTROL_STATIC_KEYS";


This works great but there is one problem.

PROBLEM When I import info from the XML file, there is one additional row that is blank in each DataGridView control. I have some other functions where I use the number of rows in the DGV as an index, and this additional row is screwing things up.

Could you tell me what I am doing wrong?

Thanks!
N.

modified on Monday, August 29, 2011 1:57 AM

QuestionHow can i get year, month different from calendar? Pin
buffering8328-Aug-11 15:17
buffering8328-Aug-11 15:17 
AnswerRe: How can i get year, month different from calendar? Pin
PIEBALDconsult28-Aug-11 16:52
mvePIEBALDconsult28-Aug-11 16:52 
AnswerRe: How can i get year, month different from calendar? Pin
Anthony Mushrow28-Aug-11 17:08
professionalAnthony Mushrow28-Aug-11 17:08 
Questionjust woundering about random numbers? Pin
stephen.darling28-Aug-11 12:02
stephen.darling28-Aug-11 12:02 
AnswerRe: Just wondering about random numbers Pin
DaveyM6928-Aug-11 13:06
professionalDaveyM6928-Aug-11 13:06 
JokeRe: just woundering about random numbers? Pin
PIEBALDconsult28-Aug-11 14:10
mvePIEBALDconsult28-Aug-11 14:10 
GeneralRe: just woundering about random numbers? Pin
stephen.darling28-Aug-11 14:57
stephen.darling28-Aug-11 14:57 
GeneralRe: just woundering about random numbers? Pin
PIEBALDconsult28-Aug-11 16:50
mvePIEBALDconsult28-Aug-11 16:50 
AnswerRe: just woundering about random numbers? Pin
ljupcecar28-Aug-11 22:55
ljupcecar28-Aug-11 22:55 
AnswerRe: just woundering about random numbers? [modified] Pin
GParkings1-Sep-11 6:33
GParkings1-Sep-11 6:33 
GeneralRe: just woundering about random numbers? Pin
stephen.darling1-Sep-11 13:45
stephen.darling1-Sep-11 13:45 
GeneralRe: just woundering about random numbers? Pin
GParkings1-Sep-11 21:58
GParkings1-Sep-11 21:58 
GeneralRe: just woundering about random numbers? Pin
stephen.darling2-Sep-11 1:15
stephen.darling2-Sep-11 1:15 
QuestionIs this a good book to learn c#? Pin
stephen.darling28-Aug-11 7:01
stephen.darling28-Aug-11 7:01 
AnswerRe: Is this a good book to learn c#? Pin
Shameel28-Aug-11 8:54
professionalShameel28-Aug-11 8:54 
GeneralRe: Is this a good book to learn c#? Pin
stephen.darling28-Aug-11 11:25
stephen.darling28-Aug-11 11:25 
AnswerRe: Is this a good book to learn c#? Pin
Eddy Vluggen28-Aug-11 9:05
professionalEddy Vluggen28-Aug-11 9:05 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.