Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Request.form from a hyperlink

Status
Not open for further replies.

mcallaghan

IS-IT--Management
Mar 22, 2005
43
0
0
US
I have a pretty general Question that I am very unclear on how to do it. I have a hyperlink that passes parameters and putting them into a details view. I dont want to put all these values into details view though. I am having no problem with grabbing these values. I just want to insert these values into the table.

I have tried putting the values into details view but making the rows invisible but that just insert the values as null values. The values I am trying to insert into the table are expc and CCID into the table Tbl_Org_Budget_Detail table.

Dim EXPC As String
EXPC = LTrim(Server.HtmlEncode(Request.QueryString("EXP")))
Dim CCID As String
CCID = LTrim(Server.HtmlEncode(Request.QueryString("CC")))

I will attach the code as well.

<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns=" >
<script runat="server">
Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
If (DetailsView1.CurrentMode = DetailsViewMode.Insert) Then
Dim stateTextBox1 As TextBox = CType(DetailsView1.Rows(3).Cells(1).Controls(0), TextBox)
stateTextBox1.Text = LTrim(Server.HtmlEncode(Request.QueryString("EXP")))
stateTextBox1.Enabled = False

Dim stateTextBox2 As TextBox = CType(DetailsView1.Rows(2).Cells(1).Controls(0), TextBox)
stateTextBox2.Text = LTrim(Server.HtmlEncode(Request.QueryString("CC")))
stateTextBox2.Text = LTrim(Server.HtmlEncode(Request.QueryString("CC")))
stateTextBox2.Enabled = False

Dim stateTextBox3 As TextBox = CType(DetailsView1.Rows(9).Cells(1).Controls(0), TextBox)
stateTextBox3.Text = LTrim(Server.HtmlEncode(Request.QueryString("CCID")))
stateTextBox3.Enabled = False

Dim stateTextBox4 As TextBox = CType(DetailsView1.Rows(8).Cells(1).Controls(0), TextBox)
stateTextBox4.Text = LTrim(Server.HtmlEncode(Request.QueryString("EXPC")))
stateTextBox4.Enabled = False


Dim ParamValue As String = LTrim(Server.HtmlEncode(Request.QueryString("CC")))
' MyDataSource.InsertParameters.Add("pAdditionalInfo", ParamValue)

Dim EXPC As String
EXPC = LTrim(Server.HtmlEncode(Request.QueryString("EXP")))
Dim CCID As String
CCID = LTrim(Server.HtmlEncode(Request.QueryString("CC")))

End If


End Sub
Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)

End Sub

Protected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs)


End Sub

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)

End Sub

Protected Sub DetailsView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewPageEventArgs)

End Sub

Protected Sub FormView1_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewPageEventArgs)

End Sub
</script>

<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Menu ID="EntertainmentMenu" runat="server" Orientation="Horizontal" BackColor="#B5C7DE" DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em" ForeColor="#284E98" StaticSubMenuIndent="10px" Width="384px" Height="40px">
<Items>
<asp:MenuItem Text="Enter Actual Budget Item" Value="Enter Actual Budget Item" NavigateUrl="~/ActualBud.aspx">
</asp:MenuItem>
<asp:MenuItem Text="Reports" Selectable="False" Value="Movies">
<asp:MenuItem Text="Budget/Actual Year Report" Value="Budget/Actual" NavigateUrl="~/BAYear.aspx" />
<asp:MenuItem Text="Budget Report" Value="Budget Report" NavigateUrl="~/Budgetrpt.aspx" />
<asp:MenuItem Text="Budget Actual Monthly Report" Value="Budget Actual Monthly Report" NavigateUrl="~/MYRep.aspx" />
<asp:MenuItem NavigateUrl=" Text="Business Objects Report" Value="Business Objects Report">
</asp:MenuItem>
</asp:MenuItem>
</Items>
<StaticSelectedStyle BackColor="#507CD1" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicHoverStyle BackColor="#284E98" ForeColor="White" />
<DynamicMenuStyle BackColor="#B5C7DE" />
<DynamicSelectedStyle BackColor="#507CD1" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticHoverStyle BackColor="#284E98" ForeColor="White" />
</asp:Menu>

<br />

<asp:DetailsView AutoGenerateRows="False" DataSourceID="SqlDataSource5"
HeaderText="Add Budget Item" ID="DetailsView1" runat="server" Width="608px" OnItemUpdated="DetailsView1_ItemUpdated" OnItemInserted="DetailsView1_ItemInserted" OnDataBound="DetailsView1_DataBound" CellPadding="4" ForeColor="#333333" GridLines="None" OnPageIndexChanging="DetailsView1_PageIndexChanging" >
<EmptyDataTemplate>
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource5" OnPageIndexChanging="FormView1_PageIndexChanging">
</asp:FormView>
</EmptyDataTemplate>
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#999999" />
<AlternatingRowStyle BackColor="White" ForeColor="#284775" /><Fields>
<asp:BoundField DataField="Manufacturer" HeaderText="Manufacturer:" SortExpression="Manufacturer" />
<asp:BoundField DataField="Lne_Item_Desc" HeaderText="Line Item Desc:" SortExpression="Lne_Item_Desc" />
<asp:BoundField DataField="ExpCode" HeaderText="Exp. Code Id:" SortExpression="ExpCode" />
<asp:BoundField DataField="CC_Code" HeaderText="CC Id:" SortExpression="CC_Code" />
<asp:BoundField DataField="Serv_Start_Date" HeaderText="Serv. Start Date:" SortExpression="Serv_Start_Date" />
<asp:BoundField DataField="Serv_End_Date" HeaderText="Serv. End Date:" SortExpression="Serv_End_Date" />
<asp:BoundField DataField="Exp_type" HeaderText="Exp. Type(Recurring,One-Time):"
SortExpression="Exp_type" />
<asp:BoundField DataField="BudgetAmt" HeaderText="BudgetAmt"
SortExpression="BudgetAmt" Visible="False" />
<asp:BoundField DataField="ExpCodeId" HeaderText="Exp. Code Id:" SortExpression="ExpCodeId" ConvertEmptyStringToNull="False" InsertVisible="False" Visible="False" />
<asp:BoundField DataField="CC_Id" HeaderText="CC_Id" SortExpression="CC_Id" ConvertEmptyStringToNull="False" InsertVisible="False" Visible="False" />
<asp:CommandField ShowInsertButton="True" />
</Fields>
</asp:DetailsView>
<asp:Label ID="ErrorMessageLabel" EnableViewState="false" runat="server" />&nbsp;&nbsp;&nbsp;&nbsp;<br />
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/ActualBud.aspx">Go Back....</asp:HyperLink>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
<asp:SqlDataSource ID="SqlDataSource5" runat="server"
ConnectionString="<%$ ConnectionStrings:AOBudgetConnectionString %>" InsertCommand="INSERT INTO Tbl_Org_Budget_Detail(BudgetId, CC_Id, ExpCodeId, Serv_Start_Date, Serv_End_Date, BudgetAmt, Pay_Due_Date, Manufacturer, Exp_type, Lne_Item_Desc) VALUES (@BudgetId, Request.QueryString(cc), Request.QueryString(EXP), @Serv_Start_Date, @Serv_End_Date, 0.00, @Pay_Due_Date, @Manufacturer, @Exp_type, @Lne_Item_Desc)"
OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT Tbl_Org_Budget_Detail.Bud_Detail_Id, Tbl_Org_Budget_Detail.BudgetId, Tbl_Org_Budget_Detail.CC_Id, Tbl_Org_Budget_Detail.ExpCodeId, Tbl_Org_Budget_Detail.VendorId, Tbl_Org_Budget_Detail.PaymentId, Tbl_Org_Budget_Detail.Serv_Start_Date, Tbl_Org_Budget_Detail.Serv_End_Date, Tbl_Org_Budget_Detail.BudgetAmt, Tbl_Org_Budget_Detail.Rev_Bud_Flag, Tbl_Org_Budget_Detail.Amort_Flag, Tbl_Org_Budget_Detail.Pay_Due_Date, Tbl_Org_Budget_Detail.Manufacturer, Tbl_Org_Budget_Detail.Exp_type, Tbl_Org_Budget_Detail.Lne_Item_Desc, Tbl_ExpCode_Master.ExpCode, Tbl_CostCenter_Master.CC_Code FROM Tbl_Org_Budget_Detail INNER JOIN Tbl_ExpCode_Master ON Tbl_Org_Budget_Detail.ExpCodeId = Tbl_ExpCode_Master.ExpenseCodeId INNER JOIN Tbl_CostCenter_Master ON Tbl_Org_Budget_Detail.CC_Id = Tbl_CostCenter_Master.CC_Id" DeleteCommand="DELETE FROM [Tbl_Org_Budget_Detail] WHERE [Bud_Detail_Id] = @original_Bud_Detail_Id" UpdateCommand="UPDATE Tbl_Org_Budget_Detail SET BudgetId = @BudgetId, CC_Id = @CC_Id, ExpCodeId = @ExpCodeId, VendorId = @VendorId, PaymentId = @PaymentId, Serv_Start_Date = @Serv_Start_Date, Serv_End_Date = @Serv_End_Date, BudgetAmt = @BudgetAmt, Rev_Bud_Flag = @Rev_Bud_Flag, Amort_Flag = @Amort_Flag, Pay_Due_Date = @Pay_Due_Date, Manufacturer = @Manufacturer, Exp_type = @Exp_type, Lne_Item_Desc = @Lne_Item_Desc WHERE (Bud_Detail_Id = @original_Bud_Detail_Id)">

<InsertParameters>
<asp:parameter Name="BudgetId" Type="Int32" />
<asp:parameter Name="Serv_Start_Date" Type="String" />
<asp:parameter Name="Serv_End_Date" Type="String" />
<asp:parameter Name="Pay_Due_Date" Type="DateTime" />
<asp:parameter Name="Manufacturer" Type="String" />
<asp:parameter Name="Exp_type" Type="String" />
<asp:parameter Name="Lne_Item_Desc" Type="String" />
</InsertParameters>
<DeleteParameters>
<asp:parameter Name="original_Bud_Detail_Id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="BudgetId" Type="Int32" />
<asp:parameter Name="CC_Id" Type="Int32" />
<asp:parameter Name="ExpCodeId" Type="Int32" />
<asp:parameter Name="VendorId" Type="Int32" />
<asp:parameter Name="PaymentId" Type="Int32" />
<asp:parameter Name="Serv_Start_Date" Type="String" />
<asp:parameter Name="Serv_End_Date" Type="String" />
<asp:parameter Name="BudgetAmt" Type="Decimal" />
<asp:parameter Name="Rev_Bud_Flag" Type="Boolean" />
<asp:parameter Name="Amort_Flag" Type="Boolean" />
<asp:parameter Name="Pay_Due_Date" Type="DateTime" />
<asp:parameter Name="Manufacturer" Type="String" />
<asp:parameter Name="Exp_type" Type="String" />
<asp:parameter Name="Lne_Item_Desc" Type="String" />
<asp:parameter Name="original_Bud_Detail_Id" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />
<br />
<br />
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<br />
<br />
<br />
&nbsp;


<br />
&nbsp;
</form>
</body>
</html>

Any help would be apreciated

Thanks
 
I just want to insert these values into the table.
What database are you using?

You need to get a general understanding of SQL and how to use ASP.NET to call sql statements. There are many examples on line.
 
I am using Sql server. I dont think it has anything to do about the database. I am just asking how to insert the request.form value into the database.

Thanks
 
I dont think it has anything to do about the database.
Yes is does. You question is how to insert data into a database.

The basic construct of an Insert statement is:
Insert Into TableName (col1, col2, ... coln)
Values(value1, value2, ... valuen)
 
Well the insert is working properly If I was to set the display the hyperling value in a details view to visible. I do need the capability to be able to insert the request.form value from a hyperlink into the table.

Example:
lets take this hyperlink

I am grabbing the page=1 and not actually displaying it on details view or on the page but I do need to insert this value being page=1 into the table.

So I am doing this
Dim stateTextBox3 As String
stateTextBox3 = LTrim(Server.HtmlEncode(Request.QueryString("Page1")))


I just dont know in my insert statement to the statetextbox3 value.

InsertCommand="INSERT INTO Tbl_Org_Budget_Detail(BudgetId, CC_Id, ExpCodeId, Serv_Start_Date, Serv_End_Date, BudgetAmt, Pay_Due_Date, Manufacturer, Exp_type, Lne_Item_Desc) VALUES (@BudgetId, Request.QueryString(cc), Request.QueryString(EXP), @Serv_Start_Date, @Serv_End_Date, 0.00, @Pay_Due_Date, @Manufacturer, @Exp_type, @Lne_Item_Desc)"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top