Protected Sub btnVoid_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnVoid.Click
Dim DBConn As New SqlConnection(ConfigurationManager.ConnectionStrings("PurchaseReqConnectionString").ConnectionString)
Dim DBCmd As New SqlCommand
Try
Dim row As GridViewRow = Me.GridView1.SelectedRow
Dim vReqID As Integer = row.Cells(1).Text
Dim sql As String
sql = "UPDATE Items SET Quantity = 0 WHERE ReqID = @ReqID" 'ItemID = @ItemID and ReqID = @ReqID"
DBConn.Open()
'Add UPDATE Statement
DBCmd = New SqlCommand(sql, DBConn)
'Add Database Parameters
DBCmd.Parameters.Add("@ReqID", SqlDbType.Int).Value = vReqID
DBCmd.ExecuteNonQuery()
Catch exp As Exception
Response.Write(exp.Message)
Label1.Text = exp.Message
End Try
'Close Database connection
DBCmd.Dispose()
DBConn.Close()
DBConn = Nothing
GridView2.DataBind()
End Sub
<asp:GridView ID="GridView2" runat="server" AllowSorting="True" AutoGenerateColumns="False"
CellPadding="4" DataKeyNames="ItemID" DataSourceID="SqlDataSource2" ForeColor="#333333"
ShowFooter="True">
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:CommandField ShowEditButton="True" UpdateText="Save" />
<asp:BoundField DataField="ItemID" HeaderText="ItemID" InsertVisible="False" ReadOnly="True"
SortExpression="ItemID" Visible="False" />
<asp:BoundField DataField="ItemNumber" HeaderText="Item #" SortExpression="ItemNumber" ReadOnly="true" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="ReqID" HeaderText="Requisition" SortExpression="ReqID" ReadOnly="true" >
<ItemStyle HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Quantity" HeaderText="Qty" SortExpression="Quantity" >
<ControlStyle Width="50px" />
<ItemStyle HorizontalAlign="Right" Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="UnitPrice" DataFormatString="{0:c}" HeaderText="Unit Price" ApplyFormatInEditMode="false"
HtmlEncode="False" SortExpression="UnitPrice" >
<ControlStyle Width="50px" />
<ItemStyle HorizontalAlign="Right" Width="50px" />
</asp:BoundField>
<asp:BoundField DataField="SubTotal" DataFormatString="{0:c}" HeaderText="SubTotal" ReadOnly="true"
HtmlEncode="False" SortExpression="SubTotal" >
<ItemStyle HorizontalAlign="Right" />
</asp:BoundField>
<asp:BoundField DataField="ModifiedBy" HeaderText="Modified By" SortExpression="ModifiedBy"
ReadOnly="True" >
<ItemStyle Wrap="False" />
</asp:BoundField>
<asp:BoundField DataField="DateModified" HeaderText="Date Modified" SortExpression="DateModified"
DataFormatString="{0:d}" HtmlEncode="False" ReadOnly="True" >
<ItemStyle Wrap="False" HorizontalAlign="Right" />
</asp:BoundField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#FF99FF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Most Valuable Expert award recognizes technology experts who passionately share their knowledge with the community, demonstrate the core values of this platform, and go the extra mile in all aspects of their contributions. This award is based off of nominations by EE users and experts. Multiple MVEs may be awarded each year.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.