Solved

insert datagrid row to temp table

Posted on 2008-10-13
5
307 Views
Last Modified: 2012-08-14
i have a grid (see below)  and want to add those items on click event to a temp table.  
it works kinda like a shopping cart.  is there a good way to do this in asp.net 2.0 ???
or should i create a table and store items??

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
                    BackColor="White" BorderColor="White" BorderStyle="Ridge" BorderWidth="2px"
                    CellPadding="3" CellSpacing="1" DataSourceID="SqlDataSource1"
                    GridLines="None" EmptyDataText="No options available">
                    <RowStyle BackColor="White" ForeColor="Black" />
                    <Columns>
                        <asp:BoundField DataField="itemdescription" HeaderText="Item"
                            ReadOnly="True"  />
                        <asp:BoundField DataField="price" DataFormatString="{0:c}" HeaderText="Price"
                            HtmlEncode="False" ReadOnly="True" SortExpression="price" />
                            <asp:TemplateField><ItemTemplate>
                                <asp:Image ID="Image1" runat="server" ImageUrl="images/tabs/configurator/addItems.jpg" /></ItemTemplate></asp:TemplateField>
                    </Columns>
                    <FooterStyle BackColor="#C6C3C6" ForeColor="Black" />
                    <PagerStyle BackColor="#C6C3C6" ForeColor="Black" HorizontalAlign="Right" />
                    <SelectedRowStyle BackColor="#9471DE" Font-Bold="True" ForeColor="White" />
                    <HeaderStyle BackColor="#FE8330" Font-Bold="True" ForeColor="#E7E7FF" />
                </asp:GridView>
0
Comment
Question by:gianitoo
  • 3
  • 2
5 Comments
 
LVL 3

Expert Comment

by:3abqari
ID: 22705963
You can opt to use a Datacache object and save that information in it and give it a name that is user specific
0
 
LVL 1

Author Comment

by:gianitoo
ID: 22706029
can you show me example???
need direction.  
the project i am working on is a configurator.  
once you get a product , you can add options (in this case the grid will have the options)  each option has a price and you will add/delete.  at the end you can generate quote based on all options and after that then i can add all the items into my database because they have been approved.  
0
 
LVL 3

Expert Comment

by:3abqari
ID: 22706072
Are you using C# or VB.NET?
0
 
LVL 1

Author Comment

by:gianitoo
ID: 22706084
vb.net
0
 
LVL 3

Accepted Solution

by:
3abqari earned 500 total points
ID: 22706281
You'll need a function BindData() that will contain the following code (keep in mind that this is pseudo code):

Define a new DataSet and name it let's say ds1 (Dim ds1 as new DataSet)
 
If (Cache["DataSet"] is NULL) Then
  gv.datasource = ds1
  gv.databind()
 ELSE
  gv.datasrouce = Cache["DataSet"]
  gv.databind()
 Endif
 
 Then, you need to create the Add, delete, and update functionalities to the gridview so that it would save it in the gridview
 And, somewhere on that same page, you would put a button that would say "Save" or "Commit" that would take the Cache["DataSet"] object and would save it back to the Database.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now