?
Solved

update multiple gridview rows at once in asp.net

Posted on 2008-11-19
1
Medium Priority
?
2,094 Views
Last Modified: 2012-06-27
I am using a gridview to allow users to enter data into multiple rows.  I want them to be able to click on one Update button and save all the rows at once.
I am using asp.net in VS 2005 and cannot find a simple way to display the gridview in edit mode.  I have found many examples for C+ but not VB.
Can I programatically databind() the gridview and then have it display the one column I need to allow data entry in edit mode??

THANKS
0
Comment
Question by:PEAKTT
1 Comment
 
LVL 4

Accepted Solution

by:
lotusnotesnewbie earned 1500 total points
ID: 23001604
Yes you can:

Update Featured Items List <asp:ImageButton ImageUrl="~/images/Update.gif" runat="server" OnClick="UpdateFeatured_Click" ID="UpdateFeatured" />

<asp:GridView ID="grdFeatured" runat="server" AllowPaging="True" AllowSorting="True" DataSourceID="dtSrcSelFeat" AutoGenerateColumns="False" BorderWidth="0px" PageSize="12" DataKeyNames="ProductID">
<Columns>
<asp:BoundField DataField="productname" HeaderText="Product Name"/>
<asp:TemplateField>
<HeaderTemplate>
Is Featured
</HeaderTemplate>
<ItemTemplate>
<asp:CheckBox ID="chkFeat" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Protected Sub UpdateFeatured_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles UpdateFeatured.Click
For Each row In GridView1.Rows
txtQty = CType(row.Findcontrol("txtQuantity"), TextBox)
' Do your stuff here
If (txtQty.Text <> "") Then
If Convert.ToInteger(txtQty.Text) > 0 Then
'Create entry into the Orders table here
 
End If
End If
Next
 
End Sub
 
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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 …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

809 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