Click here to Skip to main content
16,004,969 members
Home / Discussions / C#
   

C#

 
GeneralRe: Web Browser Control Issue Pin
classNoob24-May-07 13:41
classNoob24-May-07 13:41 
AnswerRe: Web Browser Control Issue Pin
SimulationofSai24-May-07 20:03
SimulationofSai24-May-07 20:03 
GeneralRe: Web Browser Control Issue Pin
classNoob25-May-07 6:25
classNoob25-May-07 6:25 
QuestionQuestion on C# XML programming! Pin
jubilanttiger24-May-07 12:41
jubilanttiger24-May-07 12:41 
AnswerRe: Question on C# XML programming! Pin
Dave Herren24-May-07 14:13
Dave Herren24-May-07 14:13 
QuestionHow can I resize an image for a Button? Pin
Khoramdin24-May-07 10:47
Khoramdin24-May-07 10:47 
AnswerRe: How can I resize an image for a Button? Pin
Giorgi Dalakishvili24-May-07 11:04
mentorGiorgi Dalakishvili24-May-07 11:04 
QuestionSaving Changes in DataGrid Pin
Leo Smith24-May-07 10:32
Leo Smith24-May-07 10:32 
I am having problems saving changes made in a datagrid to a database. I am using SqlDataAdapters with a generic "Select * FROM tbl" to load a dataset. I then assign the one table at a time to the control listing the contents of the table (all the tables are lookups for the application). Everything works great up to the point that the data is not being saved back to the server. It looks like it works. The problem is that it does not appear that the values in the datagrid are loaded back to the datatable. Here is how I am loading the grid (I am assuming that I am missing something basic here):

<br />
// make dataset<br />
SqlDataAdapter adp = new SqlDataAdapter("SELECT * FROM [" + sTmp + "];", dbConn);<br />
dbTableAdp.Add(adp);  // Add Adapter to an application adapter collection class<br />
adp.FillSchema(dbSet, SchemaType.Source, sTmp);<br />
adp.Fill(dbSet, sTmp);<br />
adp.AcceptChangesDuringUpdate = true;<br />
adp.ContinueUpdateOnError = true;<br />
<br />
// Set DataGrid values<br />
DataTable dt = dbSet.Tables["tablename"];<br />
if (dt != null)<br />
{<br />
    dgLookups.DataSource = dt;<br />
}<br />
<br />
// On RowLeave Event.  Attempt to save changes<br />
if (row.IsCurrentRowDirty == true)<br />
{<br />
    DataRow dr = dbSet.Tables["tablename"].Rows[e.RowIndex];<br />
    if (MessageBox.Show("Do you wish to commit changes to the database (Yes/No)?",<br />
         "Values Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==<br />
         DialogResult.Yes)<br />
    {<br />
        DataGridViewRow dgr = dgLookups.Rows[e.RowIndex];<br />
        dgr.SetValues();<br />
        dr.AcceptChanges();<br />
    }<br />
    else  // Refresh Value<br />
    {<br />
        dr.RejectChanges();<br />
    }<br />
}<br />


I am fairly new to using the DataGrid. I have tended toward using ListView since I normally don't allow direct access to the database. Any assistance will be a great help.





Leo T. Smith
Senior Programmer

AnswerRe: Saving Changes in DataGrid Pin
Muammar©24-May-07 11:05
Muammar©24-May-07 11:05 
QuestionReflection Memory Leak W2003 Pin
rmga24-May-07 10:31
rmga24-May-07 10:31 
AnswerRe: Reflection Memory Leak W2003 Pin
Luc Pattyn24-May-07 11:21
sitebuilderLuc Pattyn24-May-07 11:21 
GeneralRe: Reflection Memory Leak W2003 Pin
rmga24-May-07 13:23
rmga24-May-07 13:23 
GeneralRe: Reflection Memory Leak W2003 Pin
rmga24-May-07 13:31
rmga24-May-07 13:31 
GeneralRe: Reflection Memory Leak W2003 Pin
Luc Pattyn25-May-07 3:51
sitebuilderLuc Pattyn25-May-07 3:51 
GeneralRe: Reflection Memory Leak W2003 Pin
Luc Pattyn24-May-07 13:34
sitebuilderLuc Pattyn24-May-07 13:34 
QuestionReference to Word 2003 Pin
Larza12324-May-07 9:37
Larza12324-May-07 9:37 
AnswerRe: Reference to Word 2003 Pin
Dave Herren24-May-07 9:56
Dave Herren24-May-07 9:56 
AnswerRe: Reference to Word 2003 Pin
Muammar©24-May-07 23:48
Muammar©24-May-07 23:48 
QuestionUser control in DataGridView cell Pin
pserranop24-May-07 8:58
pserranop24-May-07 8:58 
QuestionHow to capture the final DocumentCompleted in Pin
Epsilone324-May-07 6:47
Epsilone324-May-07 6:47 
AnswerRe: How to capture the final DocumentCompleted in Pin
Epsilone324-May-07 8:08
Epsilone324-May-07 8:08 
QuestionListening to program events. Pin
Muntyness24-May-07 6:10
Muntyness24-May-07 6:10 
AnswerRe: Listening to program events. Pin
Dave Herren24-May-07 6:26
Dave Herren24-May-07 6:26 
GeneralRe: Listening to program events. Pin
Muntyness24-May-07 6:48
Muntyness24-May-07 6:48 
AnswerRe: Listening to program events. Pin
Dave Kreskowiak24-May-07 6:57
mveDave Kreskowiak24-May-07 6:57 

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.