Ask a Question related to ASP.NET Data Grid Control, Design and Development.
-
Per Hornshøj-Schierbeck #1
updating a typed dataset (newbie question?)
I created a DataGrid and bound a DataView of a typed DataSet to it (i tried
with the DataSet as well but i'd rather use the DataView as i'm using it for
sorting). I have paging working, sorting and the edit template is cool. When
i hit Update i wonder what i have to do to update the database with the user
inputted values.
Now in a perfect world the datagrid, bound to my view would have a method
for updating the selected row of the dataset/view with the templated values.
All i had to do is call myDataAdapter.Update(myDataSet) to make the changes
in the database. I've been looking for this and i can't seem to find a way
to do it though.
I found a lot of examples using a string or stored procedure to update the
values through a new Command object, but i was wondering why i shouldn't use
the automaticly generated update, delete, insert of my typed dataset? To
find the row i want to update i'd do something like this
myTypedDataRow = myTable.Rows.FindById(selectedId);
Now my biggest problem is how do i find the selectedId of the row just
edited? I already set the Key on the datagrid, so it knows the key of my
datatable, yet all the fancy methods on my DataGridEventArgs (or what it's
called - i don't have VS/my project here) all just return the index in the
datagrid - so since the Id is not the same as the index in the datagrid i
can't use it.
Anyone know how to solve this or have a good tutorial on DataGrids? I
searched for a good one, but only found very simple examples that didn't
cover my problem :(
Thanks!
Per
Per Hornshøj-Schierbeck Guest
-
Typed DataSet Question
I've created a Typed DataSet to manage a Shopping Cart for a Website. I'm trying to rewrite one of the events to check if the the ProductID already... -
xsd.exe Typed DataSet generation
Hello, I am loading a DataSet from an xml file and binding it to a hierarchical datagrid. I am trying to write some keys between the elements... -
web service newbie dataset question
Could someone please tell me whether the following is possible? I'm especially murky about step #5 :-) I'd be very grateful for pointers to an... -
Ccopying a datatable content from an untyped dataset into a table which is inside a typed dataset
Hi All, I am facing problem in copying content of table from a untyped dataset into to a table inside the typed dataset. I wanted to copy the data... -
typed dataset mysql
is there any way to "auto-generate" a typed dataset from a MySQL database from Visual Studio .NET? thanks -
Kathleen Dollard #2
Re: updating a typed dataset (newbie question?)
Per,
I assumed you were Windows.Forms because ASP.NET data binding is inherently
one way.
You have to work out your own updating strategy.
Kathleen
"Per Hornshøj-Schierbeck" <nospam@microsoft.com> wrote in message
news:#ucTpKxRDHA.212@TK2MSFTNGP10.phx.gbl...i> Hi Kathleen!
>
> Thanks for the relpy - i'll try and comment :) Perhaps i forgot to mention
> that this is an ASP.NET project, actually i only do ASP.NET so that's whyunless> forgot to mention it's not a winforms project. Perhaps that's why it's not
> working?
>> > Your datagrid is updating your DataSet, or should be. Don't have any
> > AcceptChanges between the Fill and Update (actually don't have anythey>> > you are really certain you understand why you need them)
> Yep, if i call AcceptChanges the RowStatus will change and they won't get
> updated when i call .Update()
>>> > Your typed DataSet does not have Insert, Deleted, Upate, etc. commands,
> > assumign you are usng the Microsoft typed dataset generator and have not
> > extended it.
> When i check the design-generated code all the commands are there - soon> should be there? I also checked when i created the dataset.
>> method> > > Now in a perfect world the datagrid, bound to my view would have a> way> > values.> > > for updating the selected row of the dataset/view with the templated> > changes> > > All i had to do is call myDataAdapter.Update(myDataSet) to make the> > > in the database. I've been looking for this and i can't seem to find a>> >> > > to do it though.
> > That is all you have to do. Do you have your DataAdapter, and DataSet
> > available?
> Ok great! How come there are no examples of this automaticly update? Holdthere?> a second - i'm using ASP.NET and not winforms - is there a differencemy>
>> > > Now my biggest problem is how do i find the selectedId of the row just
> > > edited? I already set the Key on the datagrid, so it knows the key ofdatagrid> it's> > > datatable, yet all the fancy methods on my DataGridEventArgs (or what> the> > > called - i don't have VS/my project here) all just return the index in> > > datagrid - so since the Id is not the same as the index in theyour> i> >> > > can't use it.
> > I am not clear why you need it. The currency manager associated withfor>> > DataGrid has a Current method.
> How do i access that? Perhaps i forgot to tell it's an <asp:DataGrid>
> control i'm using for asp.net and not winforms - is that only availablemy> winforms?
>> > > Now my biggest problem is how do i find the selectedId of the row just
> > > edited? I already set the Key on the datagrid, so it knows the key ofdatagrid> it's> > > datatable, yet all the fancy methods on my DataGridEventArgs (or what> the> > > called - i don't have VS/my project here) all just return the index in> > > datagrid - so since the Id is not the same as the index in the> i>> > > can't use it.
> I figured this part out, even though i shouldn't need this if i get the
> automaticly update to work.
> The trick was using either
> myDataSet.myTypedTable.Rows[e.Item.ItemIndex];
> or access the .DataKeys[e.Item.ItemIndex] to get the key value ;)
>
> Per
>
>
Kathleen Dollard Guest
-
Per Hornshøj-Schierbeck #3
Re: updating a typed dataset (newbie question?)
"Kathleen Dollard" <kathleen@mvps.org> wrote in message
news:%23z83cx8RDHA.2480@tk2msftngp13.phx.gbl...inherently> Per,
>
> I assumed you were Windows.Forms because ASP.NET data binding isNod thanks :) I found a way (actually two different ones i posted earlier)> one way.
>
> You have to work out your own updating strategy.
>
> Kathleen
to do it so it's cool. I just wanted to make sure i wasn't doing it the hard
way (if there was an easier one).
Per Hornshøj-Schierbeck Guest



Reply With Quote

