Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Trying to 'Add' a record to a dataset
Message
From
12/12/2004 10:39:15
 
General information
Forum:
ASP.NET
Category:
Forms
Miscellaneous
Thread ID:
00968525
Message ID:
00968603
Views:
8
Gerard,

Hmmm ... that *should* work. Can you post the relevant part of your code?

~~Bonnie



>Hi Bonnie.
>
>Thats worked fine for 'Adding' the record, as I can see that a new blank record is added ok.
>The record pointer in the Grid stays on the record it was originally positioned though.
>
>(The Grid is read only... but I woul'nt have thought that should matter ?)
>
>
>>Gerard,
>
>>
>>Yeah, it's a bit confusing at times, isn't it? <s>
>>
>>The NewRow() method doesn't actually add the new row to the DataSet. Here's how you have to do it:
>>
>>DataRow row = this.ds.Tables["MYTABLE"].NewRow();
>>// if you needed to initialize any columns:
>>row["MyFirstColumn"] = "whatever";
>>this.ds.Tables["MYTABLE"].Rows.Add(row);
>>
>>Also, since you said that you need to "go" to that row, you'll need to update the BindingContext Position, like this:
>>
>>int recno = this.ds.Tables["MYTABLE"].Rows.Count - 1;
>>this.BindingContext[this.ds.Tables["MYTABLE"]].Position = recno;
>>
>>That should do it!
>>
>>~~Bonnie
>>
>>
>>
>>>Hi.
>>>I have a form with two pages, Grid in page one and Controls in Page 2
>>>I have a Dataset displaying fine in page one, with controls in Page Two.
>>>
>>>I have an 'Add' button , the purpose of which is to 'Add' a new record
>>>I have following code in click event:
>>>this.ds.Tables["MYTABLE"].NewRow();
>>>
>>>This seems to run (.i.e does not give an error message) but I cannot see a new record in the Grid ?
>>>
>>>What I would like to do is:
>>>1. Add the new record to the Dataset Table
>>>2. 'Land' on this record (i.e. Goto MyNewDatSetRecord)
>>>3. Set focus to the first field on Page 2
>>>
>>>Any assistance greatly appeciated
>>>
>>>Regards
>>>Gerard
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform