Hello,
First of all. Im very new to ASP.NET so bear with me.
Scenario: User is presented with a web page asking for a customer number and then hits a go button. The Go button calls another page and passes on the customer number to that page. The page loads a gridview . THe girdview's datasourece loads an sqlsource. The source calls a stored procedure and passes the data back to the gridview filtered by the previoulsy obtained customer number. Here is where it gets tricky. The Gridview shows some data the procedure pulled from an existing table in the sql server. There are also some empty fields that after hitting the edit buttton, the user has to populate. Once the user populates the fields Update/insert is selected and the the insert procedure takes the record wiht added field data and inserts it into a speerate table in the sql database. WHat i need now is the gridview to show the updated record i just inserted into the new table by calling a didfferent datasource passing on the serial number the user has entered in the of the empty fields.
PS. i use VB.
below is the aspx and aspx.vb file as i have them now. THe sqldatasource3 is the source that the serial number needs to be passed on to to obtain the updatyed records in the separate sql table.
I am greatfull or any help you can give me.
~Anthony
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="REWTSCusNum.aspx.vb" Inherits="REWTSEquip" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="REWTSEquip1" EnableModelValidation="True" AllowPaging="True"
AutoGenerateEditButton="True" PageSize="4" Height="150px">
<Columns>
<asp:TemplateField HeaderText="MANUFACTURER" SortExpression="MANUFACTURER">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" maxlength='25' Text='<%# Bind("MANUFACTURER") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("MANUFACTURER") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="MODEL" SortExpression="MODEL">
<EditItemTemplate>
<asp:TextBox ID="TextBox2" runat="server" maxlength='5' Text='<%# Bind("MODEL") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("MODEL") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DESCRIPTION" SortExpression="DESCRIPTION">
<EditItemTemplate>
<asp:TextBox ID="TextBox3" runat="server" maxlength='25' Text='<%# Bind("DESCRIPTION") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label3" runat="server" Text='<%# Bind("DESCRIPTION") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SERIAL" SortExpression="SERIAL">
<EditItemTemplate>
<asp:TextBox ID="TextBox4" runat="server" maxlength='12' Text='<%# Bind("SERIAL") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label4" runat="server" Text='<%# Bind("SERIAL") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="EQUIP_ID" SortExpression="EQUIP_ID">
<EditItemTemplate>
<asp:TextBox ID="TextBox5" runat="server" maxlength='5' Text='<%# Bind("EQUIP_ID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label5" runat="server" Text='<%# Bind("EQUIP_ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CUSTOMER_NUMBER"
SortExpression="CUSTOMER_NUMBER">
<EditItemTemplate>
<asp:TextBox ID="TextBox6" runat="server" maxlength='6' Text='<%# Bind("CUSTOMER_NUMBER") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label6" runat="server" Text='<%# Bind("CUSTOMER_NUMBER") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="SERVICECOUNT" SortExpression="SERVICECOUNT">
<EditItemTemplate>
<asp:TextBox ID="TextBox7" runat="server" maxlength='6' Text='<%# Bind("SERVICECOUNT") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text='<%# Bind("SERVICECOUNT") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="LOCATION" SortExpression="LOCATION">
<EditItemTemplate>
<asp:TextBox ID="TextBox8" runat="server" maxlength='6' Text='<%# Bind("LOCATION") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("LOCATION") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="RECEIVED" SortExpression="RECEIVED">
<EditItemTemplate>
<asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("RECEIVED") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label9" runat="server" Text='<%# Bind("RECEIVED") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CONDITION" SortExpression="CONDITION">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="CONDITION"
DataValueField="CONDITION" SelectedValue='<%# Bind("CONDITION") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label10" runat="server" Text='<%# Bind("CONDITION") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="TECHNICIAN" SortExpression="TECHNICIAN">
<EditItemTemplate>
<asp:TextBox ID="TextBox11" runat="server" maxlength='6' Text='<%# Bind("TECHNICIAN") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label11" runat="server" Text='<%# Bind("TECHNICIAN") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="NOTES" SortExpression="NOTES">
<EditItemTemplate>
<asp:TextBox ID="TextBox12" runat="server" maxlength='50' Text='<%# Bind("NOTES") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label12" runat="server" Text='<%# Bind("NOTES") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DISPOSITION" SortExpression="DISPOSITION">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="SqlDataSource2" DataTextField="DISPOSITION"
DataValueField="DISPOSITION" SelectedValue='<%# Bind("DISPOSITION") %>'>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label13" runat="server" Text='<%# Bind("DISPOSITION") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="REWTSEquip1" runat="server"
ConnectionString="<%$ ConnectionStrings:REWTSEquipConnectString %>"
SelectCommand="usp_REWTSSerialEquipByCUSNUM"
SelectCommandType="StoredProcedure"
InsertCommand="INSERT INTO REWTSEquipment(MANUFACTURER, MODEL, DESCRIPTION, SERIAL, EQUIP_ID, CUSTOMER_NUMBER, SERVICECOUNT, LOCATION, RECEIVED, CONDITION, TECHNICIAN, NOTES, DISPOSITION) VALUES (@MANUFACTURER, @MODEL, @DESCRIPTION, @SERIAL, @EQUIP_ID, @CUSTOMER_NUMBER, @SERVICECOUNT, @LOCATION, @RECEIVED, @CONDITION, @TECHNICIAN, @NOTES, @DISPOSITION)"
UpdateCommand="INSERT INTO REWTSEquipment(MANUFACTURER, MODEL, DESCRIPTION, SERIAL, EQUIP_ID, CUSTOMER_NUMBER, SERVICECOUNT, LOCATION, RECEIVED, CONDITION, TECHNICIAN, NOTES, DISPOSITION) VALUES (@MANUFACTURER, @MODEL, @DESCRIPTION, @SERIAL, @EQUIP_ID, @CUSTOMER_NUMBER, @SERVICECOUNT, @LOCATION, @RECEIVED, @CONDITION, @TECHNICIAN, @NOTES, @DISPOSITION)">
<InsertParameters>
<asp:Parameter Name="MANUFACTURER" />
<asp:Parameter Name="MODEL" />
<asp:Parameter Name="DESCRIPTION" />
<asp:Parameter Name="SERIAL" />
<asp:Parameter Name="EQUIP_ID" />
<asp:Parameter Name="CUSTOMER_NUMBER" />
<asp:Parameter Name="SERVICECOUNT" />
<asp:Parameter Name="LOCATION" />
<asp:Parameter Name="RECEIVED" />
<asp:Parameter Name="CONDITION" />
<asp:Parameter Name="TECHNICIAN" />
<asp:Parameter Name="NOTES" />
<asp:Parameter Name="DISPOSITION" />
</InsertParameters>
<SelectParameters>
<asp:QueryStringParameter Name="CUSNUM" QueryStringField="CusNum"
Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="MANUFACTURER" />
<asp:Parameter Name="MODEL" />
<asp:Parameter Name="DESCRIPTION" />
<asp:Parameter Name="SERIAL" />
<asp:Parameter Name="EQUIP_ID" />
<asp:Parameter Name="CUSTOMER_NUMBER" />
<asp:Parameter Name="SERVICECOUNT" />
<asp:Parameter Name="LOCATION" />
<asp:Parameter Name="RECEIVED" />
<asp:Parameter Name="CONDITION" />
<asp:Parameter Name="TECHNICIAN" />
<asp:Parameter Name="NOTES" />
<asp:Parameter Name="DISPOSITION" />
</UpdateParameters>
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:REWTSConnectionString3 %>"
SelectCommand="SELECT [CONDITION] FROM [tbl_Condition]"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:REWTSConnectionString3 %>"
SelectCommand="SELECT [DISPOSITION] FROM [tbl_DISPOSITION]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:REWTSConnectionString5 %>"
SelectCommand="SELECT * FROM [REWTSEquipment] WHERE ([SERIAL] = @SERIAL)">
<SelectParameters>
<asp:ControlParameter ControlID="GridView1" Name="SERIAL"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:Button ID="btnLogout0" runat="server" OnClick="btnLogout_OnClick" text="Log Out" />
<asp:Button ID="Button1" runat="server" Text="BACK" />
</form>
</body>
</html>
=================================================
CODE BEHIND
Partial Class REWTSEquip
Inherits System.Web.UI.Page
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
End Sub
Sub btnLogout_OnClick(ByVal Src As Object, ByVal E As EventArgs) Handles btnLogout0.Click
FormsAuthentication.SignOut()
Response.Redirect("Default.aspx")
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("REWTSSHEET.aspx")
End Sub
Protected Sub SqlDataSource1_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource1.Selecting
End Sub
End Class