Alright I have a question that seems simple but I haven't been able to figure it out.
Just some quick details: I am using Visual Studio 2010 with ASP.NET, VB, and using SQL Server as my database
I am creating a website using ASP.NET and I have a mailing list database, I have a add to mailing list page that takes in certain fields (Name, e-mail, phone number) that are TextBox and a sumbit button. When the submit button is clicked how to do I take the current values of those text fields and add them to the database.
I have done it using the DetailedView which works at adding to the database but I also want to redirect to a different page after inserting.
So my question basically is how to take the values from the TextBox and insert them into the database, or how to I redirect to a different page after inserting a new row with DetailedView.
Here is my code with for the .aspx file, it has both the TextBox's and the detailed view
<p class=whiteMail>
First Name: <asp:TextBox ID="FirstName" runat="server"></asp:TextBox> <br />
Last Name: <asp:TextBox ID="LastName" runat="server"></asp:TextBox> <br />
E-Mail: <asp:TextBox ID="Email" runat="server"></asp:TextBox> <br />
Phone Number: <asp:TextBox ID="PhoneNumber" runat="server"></asp:TextBox> <br />
<asp:Button ID="Submit" runat="server" Text="Button" />
<br />
<asp:DetailsView ID="DetailsView2" runat="server" Height="50px" Width="125px"
DataSourceID="SqlDataSource1" AutoGenerateRows="False" CellPadding="4"
DataKeyNames="FirstName,PhoneNum,LastName" DefaultMode="Insert"
ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<EditRowStyle BackColor="#999999" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<Fields>
<asp:BoundField DataField="FirstName" HeaderText="First Name" ReadOnly="True"
SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="Last Name" ReadOnly="True"
SortExpression="LastName" />
<asp:BoundField DataField="PhoneNum" HeaderText="Phone Number" ReadOnly="True"
SortExpression="PhoneNum" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:CommandField ShowCancelButton="False" ShowInsertButton="True" />
</Fields>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:Database1ConnectionString2 %>"
DeleteCommand="DELETE FROM [MailList] WHERE [FirstName] = #FirstName AND [PhoneNum] = #PhoneNum AND [LastName] = #LastName"
InsertCommand="INSERT INTO [MailList] ([FirstName], [PhoneNum], [Email], [LastName]) VALUES (#FirstName, #PhoneNum, #Email, #LastName)"
SelectCommand="SELECT [FirstName], [PhoneNum], [Email], [LastName] FROM [MailList]"
UpdateCommand="UPDATE [MailList] SET [Email] = #Email WHERE [FirstName] = #FirstName AND [PhoneNum] = #PhoneNum AND [LastName] = #LastName">
<DeleteParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="PhoneNum" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="PhoneNum" Type="String" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="PhoneNum" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
</p>
And here is the .vb code
Public Class add
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Submit_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Submit.Click
Dim strURL As String = "message.aspx?firstname=" & FirstName.Text & "&lastname=" & LastName.Text()
Response.Redirect(strURL)
End Sub
Any help or suggestions would be great
I am not sure if I understood well, but I believe that your approach is not correct. Why you are using the textboxes in the beginning of the code?
You can achieve nicely what you want by using the full capability of the DetailsView. For example you can do something like this:
<asp:DetailsView ID="DetailsView2" runat="server" Height="50px" Width="125px"
DataSourceID="SqlDataSource1" AutoGenerateRows="False" CellPadding="4"
DataKeyNames="FirstName,PhoneNum,LastName" DefaultMode="Insert"
ForeColor="#333333" GridLines="None">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<EditRowStyle BackColor="#999999" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<Fields>
<asp:TemplateField HeaderText="FirstName" SortExpression="FirstName">
<ItemTemplate>
<asp:Label ID="Label1" runat="server"
Text='<%# Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("FirstName") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("FirstName") %>'></asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LastName" SortExpression="LastName">
<ItemTemplate>
<asp:Label ID="Label2" runat="server"
Text='<%# Bind("LastName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"
Text='<%# Bind("LastName") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox2" runat="server"
Text='<%# Bind("LastName") %>'></asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PhoneNum" SortExpression="PhoneNum">
<ItemTemplate>
<asp:Label ID="Label3" runat="server"
Text='<%# Bind("PhoneNum") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"
Text='<%# Bind("PhoneNum") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox3" runat="server"
Text='<%# Bind("PhoneNum") %>'></asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email" SortExpression="Email">
<ItemTemplate>
<asp:Label ID="Label4" runat="server"
Text='<%# Bind("Email") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server"
Text='<%# Bind("Email") %>'></asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox4" runat="server"
Text='<%# Bind("Email") %>'></asp:TextBox>
</InsertItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowCancelButton="False" ShowEditButton="True" ShowInsertButton="True" />
</Fields>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
</asp:DetailsView>
And then in you code behind you can use the events of the DetailsView to do the redirect like this:
Protected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs) Handles DetailsView1.ItemUpdated
EndEditing()
End Sub
Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs) Handles DetailsView1.ItemInserted
EndEditing()
End Sub
Private Sub EndEditing()
Response.Redirect("Default.aspx")
End Sub
I just used a the default.aspx for the redirect, but you can use any other page to redirect.
I hope that this can help you.
Related
I am using a GridView bound to a list of objects rather than a direct SQL query. The population of this if working and so are the updates. I have manually generated the insert for this gridview and this is working as well.
When trying to run the delete command from the gridview, the correct method is being called however none of the parameters are being populated. The only required parameter for this is #ID however, reading other posts, the general fix has been to add all parameters, but still to no avail.
<asp:GridView ID="GridViewBands" runat="server" AutoGenerateColumns="False" DataSourceID="BandsDataSource" CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True" Width="1375px">
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:TemplateField HeaderText="AgencyID" SortExpression="AgencyID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Width="80px" Text='<%# Bind("AgencyID") %>' ReadOnly ="true"></asp:TextBox>
<asp:RequiredFieldValidator ControlToValidate="TextBox1" runat="server" ErrorMessage="there is an error?" Text="*`"></asp:RequiredFieldValidator>
</EditItemTemplate>
<FooterTemplate>
<asp:Button ID="Button1" runat="server" CommandName="Insert" Text="Add New Line" />
<asp:TextBox ID="newAgencyID" runat="server" Width="80px"></asp:TextBox>
<br />
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("AgencyID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TypeID" SortExpression="TypeID">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Width="80px" Text='<%# Bind("TypeID") %>' ReadOnly ="true"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newTypeID" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Width="80px" Text='<%# Bind("TypeID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CompanyID" SortExpression="CompanyID">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Width="80px" Text='<%# Bind("CompanyID") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newCompanyID" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("CompanyID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Office" SortExpression="Office">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" Width="80px" Text='<%# Bind("Office") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newOffice" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("Office") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SequenceID" SortExpression="SequenceID" >
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" Width="80px" Text='<%# Bind("SequenceID") %>' ReadOnly ="true"></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newSequenceID" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("SequenceID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Minimmum" SortExpression="Minimmum">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" Width="80px" Text='<%# Bind("Minimmum") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newMinimum" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("Minimmum") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Capped" SortExpression="Capped">
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" Width="80px" Text='<%# Bind("Capped") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newCapped" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("Capped") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="fixed" SortExpression="fixed">
<EditItemTemplate>
<asp:TextBox ID="TextBox8" runat="server" Width="80px" Text='<%# Bind("fixed") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newFixed" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("fixed") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Flat" SortExpression="Flat">
<EditItemTemplate>
<asp:TextBox ID="TextBox9" runat="server" Width="80px" Text='<%# Bind("Flat") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newFlat" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("Flat") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SequenceLimit" SortExpression="SequenceLimit">
<EditItemTemplate>
<asp:TextBox ID="TextBox10" runat="server" Width="80px" Text='<%# Bind("SequenceLimit") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newSequenceLimit" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label10" runat="server" Text='<%# Bind("SequenceLimit") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Rate" SortExpression="Rate">
<EditItemTemplate>
<asp:TextBox ID="TextBox11" runat="server" Width="80px" Text='<%# Bind("Rate") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newRate" runat="server" Width="80px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Bind("Rate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ActiveFrom" SortExpression="ActiveFrom">
<EditItemTemplate>
<asp:TextBox ID="txtActiveFrom" runat="server" Width="200px" Text='<%# Bind("ActiveFrom") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newActiveFrom" runat="server" Width="200px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblActiveFrom" runat="server" Text='<%# Bind("ActiveFrom") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ActiveTo" SortExpression="ActiveTo">
<EditItemTemplate>
<asp:TextBox ID="txtActiveTo" runat="server" Width="200px" Text='<%# Bind("ActiveTo") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="newActiveTo" runat="server" Width="200px"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lblActiveTo" runat="server" Text='<%# Bind("ActiveTo") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="ID" SortExpression="ID">
<EditItemTemplate>
<asp:TextBox ID="txtID" runat="server" Width="80px" Text='<%# Bind("ID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
<SortedAscendingCellStyle BackColor="#FDF5AC" />
<SortedAscendingHeaderStyle BackColor="#4D0000" />
<SortedDescendingCellStyle BackColor="#FCF6C0" />
<SortedDescendingHeaderStyle BackColor="#820000" />
</asp:GridView>
The data source is as below, with the other working methods. It is just the delete method that isn't populating any of the parameters.
<asp:ObjectDataSource ID="BandsDataSource" runat="server" SelectMethod="SelectBands" TypeName="App_Code.Billing+BillingBand" UpdateMethod="UpdateBands" DeleteMethod="RemoveBand" InsertMethod="AddNewBand">
<SelectParameters>
<asp:Parameter Name ="AgencyID" Type ="Int64" />
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="AgencyID" Type="Object" />
<asp:Parameter Name="TypeID" Type="Object" />
<asp:Parameter Name="CompanyID" Type="Object" />
<asp:Parameter Name="Office" Type="Object" />
<asp:Parameter Name="SequenceID" Type="Object" />
<asp:Parameter Name="Minimmum" Type="Object" />
<asp:Parameter Name="Capped" Type="Object" />
<asp:Parameter Name="fixed" Type="Object" />
<asp:Parameter Name="Flat" Type="Object" />
<asp:Parameter Name="SequenceLimit" Type="Object" />
<asp:Parameter Name="Rate" Type="Object" />
<asp:Parameter Name="ActiveFrom" Type="Object" />
<asp:Parameter Name="ActiveTo" Type="Object" />
<asp:Parameter Name="ID" Type="Object" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="AgencyID" Type="Object" />
<asp:Parameter Name="TypeID" Type="Object" />
<asp:Parameter Name="CompanyID" Type="Object" />
<asp:Parameter Name="Office" Type="Object" />
<asp:Parameter Name="SequenceID" Type="Object" />
<asp:Parameter Name="Minimmum" Type="Object" />
<asp:Parameter Name="Capped" Type="Object" />
<asp:Parameter Name="fixed" Type="Object" />
<asp:Parameter Name="Flat" Type="Object" />
<asp:Parameter Name="SequenceLimit" Type="Object" />
<asp:Parameter Name="Rate" Type="Object" />
<asp:Parameter Name="ActiveFrom" Type="Object" />
<asp:Parameter Name="ActiveTo" Type="Object" />
<asp:Parameter Name="ID" Type="Object" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="AgencyID" Type="Object"/>
<asp:Parameter Name="TypeID" Type="Object" />
<asp:Parameter Name="CompanyID" Type="Object" />
<asp:Parameter Name="Office" Type="Object" />
<asp:Parameter Name="SequenceID" Type="Object" />
<asp:Parameter Name="Minimmum" Type="Object" />
<asp:Parameter Name="Capped" Type="Object" />
<asp:Parameter Name="fixed" Type="Object" />
<asp:Parameter Name="Flat" Type="Object" />
<asp:Parameter Name="SequenceLimit" Type="Object" />
<asp:Parameter Name="Rate" Type="Object" />
<asp:Parameter Name="ActiveFrom" Type="Object" />
<asp:Parameter Name="ActiveTo" Type="Object" />
<asp:Parameter Name="ID" Type="Object" />
</UpdateParameters>
</asp:ObjectDataSource>
I have tried to manually populate the parameters being using similar to the below, however I have not been able to find a way to populate the parameter based on the 'selected' line for deletion.
Protected Sub BandsDataSource_Deleting(sender As Object, e As ObjectDataSourceMethodEventArgs) Handles BandsDataSource.Deleting
e.InputParameters("ID") = GridViewBands.SelectedRow.ID.ToString()
End Sub
But this is returning a NULL reference exception.
This is the delete method for example, the update and add methods are in the same format and are working correctly.
Public Sub RemoveBand(AgencyID, TypeID, CompanyID, Office, SequenceID, Minimmum, Capped, fixed, Flat, SequenceLimit, Rate, ActiveFrom, ActiveTo, ID)
Using lCon As SqlConnection = Database.DBConnection
Dim lSqlText As String = "update billing_bands set active_to = getdate() where id = #id"
Dim lSqlCmd As New SqlCommand(lSqlText, lCon)
With lSqlCmd.Parameters
.AddWithValue("#id", ID)
End With
lSqlCmd.ExecuteNonQuery()
End Using
End Sub
Had to add into the GridView the onRowDeleting param which has to set the default values for the variables used for the delete.
<asp:GridView ID="GridViewBands" runat="server" AutoGenerateColumns="False" DataSourceID="BandsDataSource" OnRowDeleting="test" CellPadding="4" ForeColor="#333333" GridLines="None" ShowFooter="True" Width="1375px">
<AlternatingRowStyle BackColor="White" />
<Columns>
Protected Sub test(sender As Object, e As GridViewDeleteEventArgs)
Dim thisID As Integer = e.Values(13)
BandsDataSource.DeleteParameters("ID").DefaultValue = thisID
BandsDataSource.Delete()
BandsDataSource.DataBind()
BandsDataSource.Dispose()
End Sub
I have a field named status in my gridview i want it like that so that when user clickes update on gridview in the place of textfield there will be an dropdown with published and unpublished option.here is the code
<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="Id" DataSourceID="SqlDataSource3">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
<asp:BoundField DataField="info" HeaderText="info" SortExpression="info" />
<asp:BoundField DataField="productcode" HeaderText="productcode" SortExpression="productcode" />
<asp:BoundField DataField="status" HeaderText="status" SortExpression="status" />
<asp:BoundField DataField="price" HeaderText="price" SortExpression="price" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:DefaultConnection %>" DeleteCommand="DELETE FROM [product_tbl] WHERE [Id] = #Id" InsertCommand="INSERT INTO [product_tbl] ([Id], [subcat], [name], [info], [brandid], [gender]) VALUES (#Id, #subcat, #name, #info, #brandid, #gender)" SelectCommand="SELECT * FROM [product_tbl]" UpdateCommand="UPDATE [product_tbl] SET [subcat] = #subcat, [name] = #name, [info] = #info, [brandid] = #brandid, [productcode] = #productcode, [gender] = #gender WHERE [Id] = #Id">
<DeleteParameters>
<asp:Parameter Name="Id" Type="Int32" />
</DeleteParameters>
<InsertParameters>
<asp:Parameter Name="Id" Type="Int32" />
<asp:Parameter Name="subcat" Type="Int32" />
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="info" Type="String" />
<asp:Parameter Name="brandid" Type="Int32" />
<asp:Parameter Name="gender" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="subcat" Type="Int32" />
<asp:Parameter Name="name" Type="String" />
<asp:Parameter Name="info" Type="String" />
<asp:Parameter Name="brandid" Type="Int32" />
<asp:Parameter Name="productcode" Type="Int32" />
<asp:Parameter Name="gender" Type="Int32" />
<asp:Parameter Name="Id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
For dropdown list you need to place templatefield
<asp:TemplateField HeaderText="Status">
<EditItemTemplate>
<asp:DropDownList ID="ddlStautus" runat="server">
<asp:ListItem>published</asp:ListItem>
<asp:ListItem>unpublished</asp:ListItem>
</asp:DropDowList>
</asp:TempLateFeild>
and bind your gridview on code behind
for more reference use This link
OR
<asp:GridView ID="GridView1" runat="server" CellPadding="4" DataKeyNames="UserID"
ForeColor="#333333" GridLines="None"
AutoGenerateColumns="False" onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating1"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowdatabound="GridView1_RowDataBound1"
onrowdeleting="GridView1_RowDeleting">
<Columns>
<asp:TemplateField HeaderText="id" Visible="False">
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Name">
<EditItemTemplate>
<asp:TextBox ID="txtName" runat="server" Width="75px"
Text='<%# Bind("Name") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblName" runat="server"
Text='<%# Bind("Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Info">
<EditItemTemplate>
<asp:TextBox ID="txtInfo" runat="server" Width="75px"
Text='<%# Bind("Info") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblInfo" runat="server"
Text='<%# Bind("Info") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="productcode">
<EditItemTemplate>
<asp:TextBox ID="txtproductcode" runat="server" Width="75px"
Text='<%# Bind("DomainID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblproductcode" runat="server"
Text='<%# Bind("productcode") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "status">
<ItemTemplate>
<asp:Label ID="lblRole" runat="server" Text='<%# Bind("status") %>' Visible="false"/>
<asp:DropDownList ID="ddlRole" runat="server">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True"/>
<asp:TemplateField HeaderText="Delete?">
<ItemTemplate>
<span onclick="return confirm('Are you sure to Delete the record?')">
<asp:LinkButton ID="lnkB" runat="Server" Text="Delete" CommandName="Delete"></asp:LinkButton>
</span>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
and on code behind use code which is given in the link
I am trying to work on Chapter 15 exercise from Murach’s ASP.NET 4.5 web programming with C# 2012.
Here is my question.
The webpage has Grid View on the left and Details View on the right.
When I update Ahmed to Ahmad from DetailViews,
the update is not reflected in GridView.
I have to go to the next page and then come back to previous page
in order for the update to display.
I am wondering if there is any solution.
Thank you for your help!
By the way, the code is copied from the book.
<%# Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Chapter 15: Customer Maintenance</title>
<link href="Main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<header>
<img src="Images/banner.jpg" "Halloween Store" />
</header>
<section>
<form id="form1" runat="server">
<div id="gridview">
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
DataKeyNames="Email" DataSourceID="SqlDataSource1"
SelectedIndex="0"
AutoGenerateColumns="False" CellPadding="4" GridLines="None"
ForeColor="Black" Width="320px" >
<Columns>
<asp:BoundField DataField="Email" HeaderText="Email"
ReadOnly="True" Visible="False">
</asp:BoundField>
<asp:BoundField DataField="LastName" HeaderText="LastName">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle Width="150px" />
</asp:BoundField>
<asp:BoundField DataField="FirstName" HeaderText="FirstName">
<HeaderStyle HorizontalAlign="Left" />
<ItemStyle Width="120px" />
</asp:BoundField>
<asp:CommandField ButtonType="Button" ShowSelectButton="True" />
</Columns>
<HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="White" ForeColor="Black" />
<AlternatingRowStyle BackColor="#E3EAEB" ForeColor="Black" />
<SelectedRowStyle BackColor="#F46D11" ForeColor="White" />
<PagerSettings Mode="NextPreviousFirstLast" />
<PagerStyle BackColor="#1C5E55" ForeColor="White"
HorizontalAlign="Center" />
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:HalloweenConnectionString %>"
OldValuesParameterFormatString ="original_{0}"
ConflictDetection="CompareAllValues"
DeleteCommand="DELETE FROM [Customers]
WHERE [Email] = #original_Email
AND [LastName] = #original_LastName
AND [FirstName] = #original_FirstName
AND [Address] = #original_Address
AND [City] = #original_City
AND [State] = #original_State
AND [ZipCode] = #original_ZipCode
AND [PhoneNumber] = #original_PhoneNumber"
InsertCommand="INSERT INTO [Customers] ([Email], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber])
VALUES (#Email, #LastName, #FirstName, #Address, #City, #State, #ZipCode, #PhoneNumber)"
SelectCommand="SELECT [Email], [LastName], [FirstName], [Address], [City], [State], [ZipCode], [PhoneNumber]
FROM [Customers] WHERE ([Email] = #Email)"
UpdateCommand="UPDATE [Customers] SET [Email] = #Email,
[LastName] = #LastName,
[FirstName]= #FirstName,
[Address] = #Address, [City] = #City, [State] = #State, [ZipCode] = #ZipCode,
[PhoneNumber] = #PhoneNumber
WHERE [Email] = #original_Email
AND [LastName] = #original_LastName
AND [FirstName] = #original_FirstName
AND [Address] = #original_Address AND [City] = #original_City AND [State] = #original_State AND [ZipCode] = #original_ZipCode
AND [PhoneNumber] = #original_PhoneNumber">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="Email" PropertyName="SelectedValue" Type="String"/>
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="original_Email" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_State" Type="String" />
<asp:Parameter Name="original_ZipCode" Type="String" />
<asp:Parameter Name="original_PhoneNumber" Type="String" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="ZipCode" Type="String" />
<asp:Parameter Name="PhoneNumber" Type="String" />
<asp:Parameter Name="original_Email" Type="String" />
<asp:Parameter Name="original_LastName" Type="String" />
<asp:Parameter Name="original_FirstName" Type="String" />
<asp:Parameter Name="original_Address" Type="String" />
<asp:Parameter Name="original_City" Type="String" />
<asp:Parameter Name="original_State" Type="String" />
<asp:Parameter Name="original_ZipCode" Type="String" />
<asp:Parameter Name="original_PhoneNumber" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="LastName" Type="String" />
<asp:Parameter Name="FirstName" Type="String" />
<asp:Parameter Name="Address" Type="String" />
<asp:Parameter Name="City" Type="String" />
<asp:Parameter Name="State" Type="String" />
<asp:Parameter Name="ZipCode" Type="String" />
<asp:Parameter Name="PhoneNumber" Type="String" />
</InsertParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:HalloweenConnectionString %>"
SelectCommand="SELECT [Email], [LastName], [FirstName]
FROM [Customers] ORDER BY [LastName]">
</asp:SqlDataSource>
</div>
<div id="detailsview">
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="363px" AutoGenerateRows="False" DataKeyNames="Email" DataSourceID="SqlDataSource2" style="margin-left: 0px">
<Fields>
<asp:TemplateField HeaderText="Email">
<ItemTemplate>
<asp:Label ID="lblEmailIT" runat="server" Text='<%# Bind("Email") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblEmailET" runat="server" Text='<%# Bind("Email") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="txtEmailInT" runat="server" Text='<%# Bind("Email") %>'>
</asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtEmailInT" ErrorMessage="Email is a required field.">
</asp:RequiredFieldValidator>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="LastName">
<ItemTemplate>
<asp:Label ID="lblLastNameIT" runat="server" Text='<%# Bind("LastName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblLastNameET" runat="server" Text='<%# Bind("LastName") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblLastNameInT" runat="server" Text='<%# Bind("LastName") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="FirstName">
<ItemTemplate>
<asp:Label ID="lblFirstNameIT" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblFirstNameET" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblFirstNameInT" runat="server" Text='<%# Bind("FirstName") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemTemplate>
<asp:Label ID="lblAddressIT" runat="server" Text='<%# Bind("Address") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblAddressET" runat="server" Text='<%# Bind("Address") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblAddressInT" runat="server" Text='<%# Bind("Address") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="City">
<ItemTemplate>
<asp:Label ID="lblCityIT" runat="server" Text='<%# Bind("City") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblCityET" runat="server" Text='<%# Bind("City") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblCityInT" runat="server" Text='<%# Bind("City") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="State">
<ItemTemplate>
<asp:Label ID="lblStateIT" runat="server" Text='<%# Bind("State") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblStateET" runat="server" Text='<%# Bind("State") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblStateInT" runat="server" Text='<%# Bind("State") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="ZipCode">
<ItemTemplate>
<asp:Label ID="lblZipCodeIT" runat="server" Text='<%# Bind("ZipCode") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblZipCodeET" runat="server" Text='<%# Bind("ZipCode") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblZipCodeInT" runat="server" Text='<%# Bind("ZipCode") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:TemplateField HeaderText="PhoneNumber">
<ItemTemplate>
<asp:Label ID="lblPhoneNumberIT" runat="server" Text='<%# Bind("PhoneNumber") %>'>
</asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="lblPhoneNumberET" runat="server" Text='<%# Bind("PhoneNumber") %>'>
</asp:TextBox>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="lblPhoneNumberInT" runat="server" Text='<%# Bind("PhoneNumber") %>'>
</asp:TextBox>
</InsertItemTemplate>
<HeaderStyle HorizontalAlign="Left" Width="100px" />
<ItemStyle Width="200px" />
</asp:TemplateField>
<asp:CommandField ButtonType="Button" ShowDeleteButton="true" ShowEditButton="true" ShowInsertButton="true" />
</Fields>
</asp:DetailsView>
<asp:ValidationSummary ID="ValidationSummary1" runat="server"
HeaderText="Please correct the following errors:" CssClass="error" />
<p>
<asp:Label ID = "lblError" runat="server" EnableViewState="False" CssClass="error">
</asp:Label>
</p>
</div>
</form>
</section>
</body>
</html>
Yes, in your behind code under the Page_Load method insert
if(!Page.IsPostBack)
{
GridView1.DataBind();
}
You have to use this event into this event you can bind the Gridview and to redirect the the same page your data will be reflected on your Gridview
Hope this will help try this....
protected void DetailsView1_ItemUpdated(object sender, DetailsViewUpdatedEventArgs e)
{
if (e.AffectedRows == 1)
{
GridView1.DataBind();
Response.Redirect("Yourpage.aspx");
}
}
I'm hoping someone can help me get data from a GridView into another GridView I made inside it. I'm trying to get the wo_id field from the first GridView into the second GridView's datasource (created inside the first).
Right now, in the code below, I have "tasks = tasks" in the WHERE clause of the "partsused" SqlDataSource, and I want it to use the wo_id field from the parent GridView instead (thus showing the correct list of parts for the specific work order).
<%# Page Language="VB" MaintainScrollPositionOnPostback="true" MasterPageFile="~/Main.master"
AutoEventWireup="false" CodeFile="WorkOrders.aspx.vb" Inherits="PendingWO" Title="Standard Work Orders" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<center>
<h3>
Standard Work Orders</h3>
<asp:LinkButton ID="lbPrintVersion" runat="server">View Printable Version</asp:LinkButton><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="wo_id"
DataSourceID="workOrders" BackColor="White" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" CellPadding="3" GridLines="Vertical" EmptyDataText="No records"
PageSize="5">
<Columns>
<asp:ButtonField Text="Button" Visible="False" />
<asp:CommandField ShowEditButton="True" />
<asp:TemplateField SortExpression="wo_id" HeaderText="Work Order">
<ItemTemplate>
<asp:Label ID="lblWONum" runat="server" Text='<%# Eval("wo_id") %>' Font-Size="X-Large" /><br />
<asp:ImageButton ID="btnHours" runat="server" ImageUrl="~/App_Themes/Images/hoursClock.png"
Height="40px" Width="40px" ToolTip="Hours" CommandName="Hours" />
<asp:ImageButton ID="btnParts" runat="server" Height="40px" ImageUrl="~/App_Themes/Images/parts.png"
Width="40px" ToolTip="Parts Used" CommandName="Parts" />
<asp:HiddenField ID="hfColor" runat="server" Value='<%# Eval("machine_status_color") %>' />
</ItemTemplate>
<EditItemTemplate>
session("workorderid") = '<%# Eval("wo_id") %>'
<asp:Label ID="lblWONum" runat="server" Text='<%# Eval("wo_id") %>' Font-Size="X-Large" />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:GridView ID="GridView1" runat="server" DataSourceID="partsUsed" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical" DataKeyNames="parts_used_id">
<Columns>
<asp:ButtonField Text="Button" Visible="False" />
<asp:BoundField DataField="parts_used_id" HeaderText="parts_used_id" InsertVisible="False"
ReadOnly="True" SortExpression="parts_used_id" Visible="False" />
<asp:BoundField DataField="tasks" HeaderText="Work Order" ReadOnly="True"
SortExpression="tasks" />
<asp:TemplateField HeaderText="Part" SortExpression="Part">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="partsList" DataTextField="Part"
DataValueField="part_id" SelectedValue='<%# Bind("part_id") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("Part") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="part_id" HeaderText="part_id" SortExpression="part_id"
Visible="False" />
<asp:BoundField DataField="quantity" HeaderText="Quantity" SortExpression="quantity" />
<asp:BoundField DataField="cost" DataFormatString="{0:C}" HeaderText="Price Per" SortExpression="cost" />
<asp:BoundField DataField="full_name" HeaderText="Entered By"
SortExpression="full_name" ReadOnly="True" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDelete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<EmptyDataTemplate>
No Parts Logged<br />
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="250px" />
<EditItemTemplate>
<asp:HiddenField ID="hfWOId" runat="server" Value='<%# Eval("wo_id") %>' />
<asp:HiddenField ID="hfDept" runat="server"
Value='<%# Eval("machine_type_id") %>' Visible = "false" />
<asp:HiddenField ID="hfMachine" runat="server"
Value='<%# Eval("machine_id") %>' />
<asp:HiddenField ID="hfReason" runat="server"
Value='<%# Eval("reason_id") %>' />
<asp:SqlDataSource ID="sqlDepartments" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [type_description], [machine_type_id] FROM [list_machine_types] ORDER BY [type_description]">
</asp:SqlDataSource>
<asp:DropDownList ID="ddlDepartment" runat="server" DataSourceID="sqlDepartments" Visible = "false"
DataTextField="type_description" DataValueField="machine_type_id" SelectedValue='<%# Bind("machine_type_id") %>'
AutoPostBack="True"
onselectedindexchanged="ddlDepartment_SelectedIndexChanged">
</asp:DropDownList>
<br />
<asp:Label ID="Label30" runat="server" Font-Bold="true" Text="Machine Number:" Visible = "false"></asp:Label>
<asp:DropDownList ID="ddlMachine" runat="server" Visible = "false">
</asp:DropDownList>
<br />
<asp:Label ID="Label10" runat="server" Font-Bold="true" Text="Serial Number:" Visible = "false"></asp:Label><asp:Label
ID="lblSerialNum" runat="server" Text='<% #Eval("serial_number") %>' Visible = "false"></asp:Label><asp:Label
ID="Label50" runat="server" Font-Bold="true" Text="Machine Status:" Visible = "false"></asp:Label>
<asp:DropDownList ID="ddlMachineStatus" runat="server" DataSourceID="machineStatus" Visible = "false"
DataTextField="machine_status_desc" DataValueField="machine_status_id" SelectedValue='<%# Bind("machine_status_id") %>'>
</asp:DropDownList>
<br />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Department:"></asp:Label>
<asp:Label ID="lblReason" runat="server" Text='<%# Eval("reason_desc") %>'></asp:Label> <br />
<asp:Label ID="Label29" runat="server" Text="Issued To:" Font-Bold="true"></asp:Label> 
<asp:Label ID="lblIssuedTo" runat="server" Text='<% #Eval("issue_to_desc") %>'></asp:Label><br />
<asp:Label ID="Label39" runat="server" Text="Description:" Font-Bold="true"></asp:Label><br />
<asp:Label ID="lblDescription" runat="server" Text='<% #Eval("work_order_desc") %>'></asp:Label><br />
<asp:Label ID="lblMaterialLabel" runat="server" Text="Material:" Font-Bold="true" Visible="false"></asp:Label> 
<asp:Label ID="lblMaterial" runat="server" Text='<% #Eval("material_nbr_MATNR") %>' Visible="false"></asp:Label><br />
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="250px" Wrap="True" />
<EditItemTemplate>
<asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Department:"></asp:Label>
<asp:DropDownList
ID="ddlReason" runat="server">
</asp:DropDownList>
<asp:Label ID="Label29" runat="server" Font-Bold="true" Text="Issued To:"></asp:Label>
<asp:DropDownList ID="ddlIssuedTo" runat="server" DataSourceID="issuedTo" DataTextField="issue_to_desc"
DataValueField="issued_to" SelectedValue='<%# Bind("issued_to") %>'>
</asp:DropDownList>
<br />
<asp:Label ID="Label39" runat="server" Font-Bold="true" Text="Description:"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server" Height="54px" Text='<%# Bind("work_order_desc") %>'
Width="273px" TextMode="MultiLine"></asp:TextBox><br />
<asp:Label ID="lblMaterialLabel" runat="server" Text="Material:" Font-Bold="true" Visible="false"></asp:Label> 
<asp:DropDownList ID="ddlMaterial" runat="server" AppendDataBoundItems="True" Visible="false"
DataSourceID="sqlMaterials" DataTextField="material_nbr_MATNR"
DataValueField="material_nbr_MATNR"
SelectedValue='<%# Bind("material_nbr_MATNR") %>'>
<asp:ListItem Enabled="true" Text="None" Value="None" />
</asp:DropDownList>
<br />
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="Label28" runat="server" Text="Requested By:" Font-Bold="true"></asp:Label> 
<asp:Label ID="lblRequestedBy" runat="server" Text='<% #Eval("requested_by") %>'></asp:Label><br />
<asp:Label ID="Label48" runat="server" Text="Requested On:" Font-Bold="true"></asp:Label> 
<asp:Label ID="lblRequestedOn" runat="server" Text='<% #Eval("requested_on", "{0:d}") %>'></asp:Label><br />
<asp:Label ID="Label78" runat="server" Text="Required By:" Font-Bold="true"></asp:Label> 
<asp:Label ID="lblRequiredBy" runat="server" Text='<% #Eval("required_by", "{0:d}") %>'></asp:Label>
<br />
<asp:Label ID="Label77" runat="server" Text="WO Status:" Font-Bold="true"></asp:Label>
<asp:LinkButton ID="lbWOStatus" runat="server" Text='<% #Eval("status_description") %>'
CommandName="ChangeWOStatus"></asp:LinkButton>
<asp:DropDownList ID="ddlWOStatus" Visible="False" runat="server" AutoPostBack="True"
DataSourceID="woStatus" DataTextField="status_description" DataValueField="status_id"
OnSelectedIndexChanged="updateWOStatus" SelectedValue='<%# Bind("wo_status_id") %>'>
</asp:DropDownList>
<asp:LinkButton ID="lbCancel" runat="server" CommandName="CancelStatusChange" Visible="False">Cancel</asp:LinkButton><br />
</ItemTemplate>
<ItemStyle HorizontalAlign="Left" Width="250px" />
<EditItemTemplate>
<asp:Label ID="Label28" runat="server" Font-Bold="true" Text="Requested By:"></asp:Label>
<asp:Label ID="lblRequestedBy" runat="server" Text='<% #Eval("requested_by") %>'></asp:Label><br />
<asp:Label ID="Label48" runat="server" Font-Bold="true" Text="Requested On:"></asp:Label>
<asp:Label ID="lblRequestedOn" runat="server" Text='<% #Eval("requested_on", "{0:d}") %>'></asp:Label><br />
<asp:Label ID="Label78" runat="server" Font-Bold="true" Text="Required By:"></asp:Label>
<asp:TextBox ID="txtRequiredBy" runat="server" Text='<%# Bind("required_by") %>'
Width="100px"></asp:TextBox><br />
<asp:Label ID="Label77" runat="server" Font-Bold="true" Text="WO Status:"></asp:Label>
<asp:Label ID="lblWOStatus" runat="server" Text='<%# Eval("status_description") %>'></asp:Label>
<br />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" Enabled="True" SelectedDate='<%# Eval("required_by") %>'
TargetControlID="txtRequiredBy">
</asp:CalendarExtender>
<asp:LinkButton ID="lbWOStatus" runat="server" CommandName="ChangeWOStatus" Text='<% #Eval("status_description") %>'
Visible="False"></asp:LinkButton>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnApprove" runat="server" Text="Approve" BackColor="#00C000" Font-Size="Medium"
Height="40px" Width="70px" CommandName="Approve" />
<br />
<asp:Button ID="btnDeny" runat="server" Text="Deny" BackColor="#C00000" Font-Size="Medium"
ForeColor="Black" Height="40px" Width="70px" CommandName="Deny" />
<br />
<asp:Label ID="lblPending" runat="server" Text="Pending Approval" Visible="False"></asp:Label>
</ItemTemplate>
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField ID="hfPriority" runat="server" Value='<%# Eval("priority", "{0:N}") %>' />
<asp:HiddenField ID="hfApprovalStatus" runat="server" Value='<% #Eval("approval_status_id") %>' />
<asp:ImageButton ID="btnTopPriority" runat="server" CommandName="MakeTopPriority"
ImageUrl="~/App_Themes/Images/priority.png" /><br />
<asp:ImageButton ID="btnUp" runat="server" Height="40px" ImageUrl="~/App_Themes/Images/upArrow.png"
Width="40px" CommandName="Up" /><br />
<asp:ImageButton ID="btnDown" runat="server" Height="40px" ImageUrl="~/App_Themes/Images/downArrow.png"
Width="40px" CommandName="Down" /><br />
<asp:LinkButton ID="lbChangePriority" runat="server" CommandArgument='<%# Eval("wo_id") %>'
CommandName="ChangePriority">Notify New Priority</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbDelete" runat="server" CommandArgument='<%# Eval("wo_id") %>'
CommandName="DeleteWO">Delete</asp:LinkButton>
<br />
<br />
<asp:LinkButton ID="lbMoveToProjects" runat="server" CommandArgument='<%# Eval("wo_id") %>'
CommandName="MoveToProjects" OnClientClick="javascript:return confirm('Are you sure you want to move this to projects?')" Visible="false">Move To Projects</asp:LinkButton>
<br />
<br />
<asp:LinkButton ID="lbEngineeringChange" runat="server" CommandArgument='<%# Eval("wo_id") %>' CommandName="EngineeringChange" Visible="false">Push For Engineering Change</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lbPrintISO" runat="server" CommandName="PrintISO">Print ISO</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>
No work orders.<br />
</EmptyDataTemplate>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
</center>
<br />'
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<center>
<asp:SqlDataSource ID="workOrders" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="sp_WorkOrders"
UpdateCommand="UPDATE fact_work_orders SET machine_id = #machine_id, reason_id = #reason_id, machine_status_id = #machine_status_id, issued_to = #issued_to, work_order_desc = #work_order_desc, material_nbr_MATNR = #material_nbr_MATNR, required_by = #required_by WHERE wo_id = #wo_id"
SelectCommandType="StoredProcedure">
<UpdateParameters>
<asp:Parameter Name="machine_id" />
<asp:Parameter Name="reason_id" />
<asp:Parameter Name="machine_status_id" />
<asp:Parameter Name="issued_to" />
<asp:Parameter Name="work_order_desc" />
<asp:Parameter Name="material_nbr_MATNR" />
<asp:Parameter Name="required_by" />
<asp:Parameter Name="wo_id" Type="Int16" />
</UpdateParameters>
<SelectParameters>
<asp:QueryStringParameter Name="issuedTo" QueryStringField="issuedTo" DefaultValue="0" />
<asp:QueryStringParameter Name="woStatus" QueryStringField="woStatus" Type="String"
DefaultValue="%" />
<asp:SessionParameter DefaultValue="0" Name="level" SessionField="level" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="woStatus" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [status_description], [status_id] FROM [list_wo_status] WHERE ([status_id] <> #status_id)">
<SelectParameters>
<asp:Parameter DefaultValue="3" Name="status_id" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="machineStatus" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [machine_status_desc], [machine_status_id] FROM [list_machine_status]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="departments" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [type_description], [machine_type_id] FROM [list_machine_types]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="issuedTo" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [issued_to], [issue_to_desc] FROM [list_issued_to]"></asp:SqlDataSource>
<asp:SqlDataSource ID="sqlMaterials" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [material_nbr_MATNR] FROM [vdim_materials] ORDER BY [material_nbr_MATNR]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="partsUsed" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
DeleteCommand="DELETE FROM [fact_parts_used] WHERE [parts_used_id] = #parts_used_id"
InsertCommand="INSERT INTO [fact_parts_used] ([wo_id], [part_id], [quantity]) VALUES (#wo_id, #part_id, #quantity)"
SelectCommand="SELECT * FROM
(SELECT parts_used_id, dim_users.[user_name], full_name,
wo_id as tasks,
fact_parts_used.part_id, dim_parts.part_number+' '+dim_parts.part_desc as Part, quantity, cost
FROM fact_parts_used
INNER JOIN dim_users ON dim_users.[user_id] = fact_parts_used.[user_id]
INNER JOIN dim_parts ON dim_parts.part_id = fact_parts_used.part_id
) a
WHERE tasks is not null AND tasks = tasks "
UpdateCommand="UPDATE [fact_parts_used] SET [part_id] = #part_id, [quantity] = #quantity, cost = #cost WHERE [parts_used_id] = #parts_used_id"
>
<SelectParameters>
</SelectParameters>
<DeleteParameters>
<asp:Parameter Name="parts_used_id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="part_id" Type="Int32" />
<asp:Parameter Name="quantity" Type="Int32" />
<asp:Parameter Name="parts_used_id" Type="Int32" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="wo_id" Type="Int32" />
<asp:Parameter Name="part_id" Type="Int32" />
<asp:Parameter Name="quantity" Type="Int32" />
</InsertParameters>
</asp:SqlDataSource>
</center>
</asp:Content>
I have a gridview that uses accessdatasource which has select, insert, delete and update. It used to work before perfectly but all of a sudden the update stopped working while the rest are still working as they supposed to be. I haven't changed anything in the gridview or datasource, but I added new fields to the table but are not displayed in gridview. I tested by deleting the new fields from the table which did not work either. Refreshed the datasoure and gridview as well. Here is the code
asp:GridView ID="GridView1" runat="server" AllowSorting="True"
ShowFooter="True" EmptyDataText="There are no records for the selection"
AutoGenerateColumns="False" CellPadding="4" OnRowCommand="Insert_Click"
OnRowUpdating="beforeUpdate"
DataKeyNames="Lab Name,Target,Device Name"
ForeColor="#333333" HorizontalAlign="Center"
EmptyDataRowStyle-HorizontalAlign="Center"
EmptyDataRowStyle-VerticalAlign="Middle" Width="1333px"
DataSourceID="AccessDataSource8">
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<EmptyDataRowStyle Wrap="False" />
<Columns>
<asp:TemplateField ShowHeader="False">
<EditItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True"
CommandName="Update" Text="Update"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Cancel" Text="Cancel"></asp:LinkButton>
</EditItemTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False"
CommandName="Edit" Text="Edit"></asp:LinkButton>
<asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False"
CommandName="Delete" Text="Delete" OnClientClick="return confirm('Are you sure?');" ></asp:LinkButton>
</ItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="LinkButton" runat="server" CommandName="Insert" Text="Insert" ValidationGroup="validate" ></asp:LinkButton>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Lab Name" SortExpression="Lab Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("[Lab Name]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("[Lab Name]") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtLabname" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="LabName" runat="server" ControlToValidate="txtLabname" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Target" SortExpression="Target">
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Target") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Eval("Target") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtTarget" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Target" runat="server" ControlToValidate="txtTarget" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Device Name" SortExpression="Device Name">
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("[Device Name]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Eval("[Device Name]") %>'></asp:Label>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtDevicename" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Devicename" runat="server" ControlToValidate="txtDevicename" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IO Type Requirement"
SortExpression="IO Type Requirement">
<ItemTemplate>
<asp:Label ID="Label4" runat="server"
Text='<%# Bind("[IO Type Requirement]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"
Text='<%# Bind("[IO Type Requirement]") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtIotyperequirement" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Iotyperequirement" runat="server" ControlToValidate="txtIotyperequirement" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Part Number" SortExpression="Part Number">
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("[Part Number]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("[Part Number]") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtPartnumber" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Partnumber" runat="server" ControlToValidate="txtPartnumber" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Sub Part" SortExpression="Sub Part">
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("[Sub Part]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("[Sub Part]") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSubpart" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Subpart" runat="server" ControlToValidate="txtSubpart" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Subpart Description"
SortExpression="Subpart Description">
<ItemTemplate>
<asp:Label ID="Label7" runat="server"
Text='<%# Bind("[Subpart Description]") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server"
Text='<%# Bind("[Subpart Description]") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txtSubpartdesc" runat="server" ></asp:TextBox>
<asp:RequiredFieldValidator ID="Subpartdesc" runat="server" ControlToValidate="txtSubpartdesc" Text="*" ValidationGroup="validate"/>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" VerticalAlign="Middle" Wrap="False" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775"
VerticalAlign="Middle" Wrap="False" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource8" runat="server" CancelSelectOnNullParameter="False"
DataFile="~/App_Data/Test.mdb"
SelectCommand="SELECT Lab1.[Lab Name], Lab1.[Target], Lab1.[Device Name], Lab1.[IO Type Requirement], Lab1.[Part Number], Lab1.[Sub Part], Lab1.[Subpart Description]
FROM Lab1
WHERE
(((Lab1.[Lab Name])= [WhichLab] OR [WhichLab] = '0') AND
((Lab1.[Target])= [WhichTarget] OR [WhichTarget] = '0') AND
((Lab1.[Device Name])= [WhichDevice] OR [WhichDevice] = '0') AND
((Lab1.[IO Type Requirement])= [Whichiotyperequirement] OR [Whichiotyperequirement] = '0') AND
((Lab1.[Part Number])= [WhichPartNumber] OR [WhichPartNumber] = '0') AND
((Lab1.[Sub Part])= [WhichSubPart] OR [WhichSubPart] = '0') AND
((Lab1.[Subpart Description])= [WhichSubPartDesc] OR [WhichSubPartDesc] = '0')
)" UpdateCommand= " UPDATE [Lab1] SET [IO Type Requirement]= ?, [Part Number]= ?, [Sub Part]= ?, [Subpart Description]= ?
WHERE ([Lab Name]= ?) AND ([Target]= ?) AND ([Device Name] = ?)"
InsertCommand= "INSERT INTO LAB1 ([Lab Name],[Target],[Device Name],[IO Type Requirement],[Part Number],[Sub Part],[Subpart Description]) VALUES
([WhichLab],[WhichTarget],[WhichDevice],[Whichiotyperequirement],[WhichPartNumber],[WhichSubPart],[WhichSubPartDesc]) "
DeleteCommand= " Delete from LAB1 WHERE LAB1.[Lab Name]= [WhichLab] AND Lab1.[Target]=[WhichTarget] AND Lab1.[Device Name]=[WhichDevice]">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="Lab Name" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList2" Name="Target" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList3" Name="Device Name" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList4" Name="IO Type Requirement" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList5" Name="Part Number" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList6" Name="Sub Part" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
<asp:ControlParameter ControlID="DropDownList7" Name="Subpart Description" ConvertEmptyStringToNull="true" PropertyName="SelectedValue" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="IO Type Requirement" Type="String"/>
<asp:Parameter Name="Part Number" Type="String"/>
<asp:Parameter Name="Sub Part" Type="String" />
<asp:Parameter Name="Subpart Description" Type="String"/>
<asp:Parameter Name="Lab Name" Type="String"/>
<asp:Parameter Name="Target" Type="String"/>
<asp:Parameter Name="Device Name" Type="String"/>
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Lab Name" Type="String" />
<asp:Parameter Name="Target" Type="String" />
<asp:Parameter Name="Device Name" Type="String" />
<asp:Parameter Name="IO Type Requirement" Type="String" />
<asp:Parameter Name="Part Number" Type="String" />
<asp:Parameter Name="Sub Part" Type="String" />
<asp:Parameter Name="Subpart Description" Type="String" />
</InsertParameters>
<DeleteParameters>
<asp:Parameter Name="Lab Name" Type="String" />
<asp:Parameter Name="Target" Type="String" />
<asp:Parameter Name="Device Name" Type="String" />
</DeleteParameters>
</asp:AccessDataSource>
One of the fields in your WHERE clause:
WHERE ([Lab Name]= ?) AND ([Target]= ?) AND ([Device Name] = ?)"
...is not matching records. Maybe there are trailing spaces in one or more of the fields.
"ABC" will not match "ABC "