Advertisement
Advertisement
| 06.23.2008 at 05:38PM PDT, ID: 23509580 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: |
The quires I use manually:
INSERT INTO tblArchive(OrderID, UnitSerialNumber, Class, Type, Status, Title, Inactive)
Select OrderID AS OrderID, UnitSerialNumber AS UnitSerialNumber, Class AS Class, Type As Type, Status As Status, Title AS Title, Inactive AS Inactive
FROM tblActive
WHERE Inactive = 1;
DELETE FROM tblActive
WHERE Inactive = 1
aspx Page Code
---------------
<asp:GridView ID="GridView1" runat="server" AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="OrderID" DataSourceID="AllJobs">
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="OrderID" DataNavigateUrlFormatString="frmTMAPListings.aspx?OrderID={0}"
Text="Order" />
<asp:TemplateField HeaderText="Order">
<ItemTemplate>
<asp:CheckBox ID="ProcessJob" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="OrderID" HeaderText="Order ID" ReadOnly="True" SortExpression="OrderID" />
<asp:BoundField DataField="UnitSerialNumber" HeaderText="UnitSerialNumber" SortExpression="UnitSerialNumber" />
<asp:BoundField DataField="Class" HeaderText="Class" SortExpression="Class" />
<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
<asp:BoundField DataField="Status" HeaderText="status" SortExpression="Status" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:TemplateField HeaderText="Inactive">
<ItemTemplate>
<asp:CheckBox ID="cbxInactive1" runat="server" Checked='<%# Bind("Inactive") %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="AllJobs" runat="server" ConnectionString="<%$ ConnectionStrings:JobConnectionString %>"
SelectCommand="SELECT OrderID, UnitSerialNumber, Class, Type, Status, Title, Inactive FROM tblActive WHERE (Class = @Class) ORDER BY Class, Type" ProviderName="<%$ ConnectionStrings:JobsConnectionString.ProviderName %>">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Class" PropertyName="SelectedValue" />
</SelectParameters>
</asp:SqlDataSource>
<asp:LinkButton ID="btnRmvActiveRecords" runat="server" Visible="False">LinkButton</asp:LinkButton><br />
Code Behind Page
----------------
Protected Sub btnRmvActiveRecords_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnRmvActiveRecords.Click
Dim atLeastOneRowSeleted As Boolean = False
Dim ids As New StringCollection
' Iterate through the Rows
For Each row As GridViewRow In GridView1.Rows
' Access the CheckBox
Dim cb As CheckBox = row.FindControl("cbxInactive")
If cb IsNot Nothing AndAlso cb.Checked Then
atLeastOneRowSeleted = True
' First, get the OrderID for the selected row
Dim OrderID As Integer = _
Convert.ToInt32(GridView1.DataKeys(row.RowIndex).Value)
ids.Add(OrderID.ToString)
End If
Next
'Execute SQL
Dim cmd As New SqlClient.SqlCommand()
cmd.Connection = New SqlConnection(Me.AllJobs.ConnectionString)
cmd.CommandText = "INSERT INTO tblArchive(OrderID, UnitSerialNumber, Class, Type, Status, Title, Inactive) Select OrderID AS OrderID, UnitSerialNumber AS UnitSerialNumber, Class AS Class, Type As Type, Status As Status, Title AS Title, Inactive AS Inactive FROM tblActive WHERE Inactive = 1; DELETE FROM tblActive WHERE Inactive = 1"
cmd.Connection.Open()
cmd.Connection.Close()
|