472,779 Members | 1,802 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 software developers and data experts.

Insert Data Into Table with GridView or Calling Function

I am new at this, and have been trying to insert data into a table by using the footer of a gridview (which I dont like) or by using a detials view on the same page that is doing the following:

1) gets query string from url and filters records (works great) via a Details View
2) shows notes that have been added to the record shown in the details view using a grid view, and it filters the data by looking at the ID that is selected in the detailsview. (so Gridview filters by the detiailsview1.selectedvalue) Which works great..
3) I want to add a note that is related to the record by NoteID, so I added another Details view that has insert enabled and as long as I manually type the "DealID" which is not the PK for the table, I can add the note to the record. BUT if I create template controls out of the second detailsview and call a function that gets the selected value of the 1st details view (which populated the textbox correctly) and I hit Insert, nothing happens.

Using VB in visual Studio 2005
I have defaulted the view to insert mode.

Here is the code I use for getting the value to populate the Textbox (Ive tried both GetDeaalID() and GetNoteID() methods defined here which populates the control in the insert mode, but nothing happens when I enter text and click insert on the web form.):

Partial Class CallCenter_Default
Inherits System.Web.UI.Page

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

Dim Username As String = " "
Session("Username") = Request.ServerVariables("Auth_user")
Label1.Text = Session("Username")

End Sub

Protected Function GetDealID()
Dim sDealID As String = ""
sDealID = Request.QueryString("vendor_ID")
Return sDealID
End Function

Protected Function GetViewID()
Dim sViewID As String = ""
sViewID = DetailsView1.SelectedValue
Return sViewID
End Function

End Class


And Here is the snippet from my DetailsView:

<asp:DetailsView ID="DetailsView4" runat="server" AutoGenerateRows="False" DataKeyNames="NoteID"
DataSourceID="SqlDataSource1" Height="50px" Width="125px">
<asp:TemplateField HeaderText="DealID" SortExpression="DealID">
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("DealID") %>'></asp:TextBox>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# GetViewID() %>'></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("DealID") %>'></asp:Label>
<asp:BoundField DataField="login" HeaderText="login" SortExpression="login" />
<asp:BoundField DataField="Note" HeaderText="Note" SortExpression="Note" />
<asp:CommandField ShowInsertButton="True" />

__________________________________________________ ___

Here is My Datasource Code:

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:PCVSQLTestConnectionString %>"
DeleteCommand="DELETE FROM [Notes] WHERE [NoteID] = @NoteID" InsertCommand="INSERT INTO [Notes] ([DealID], [login], [Note]) VALUES (@DealID, @login, @Note)"
SelectCommand="SELECT [DealID], [NoteID], [login], [Note] FROM [Notes] WHERE ([DealID] = @DealID)"
UpdateCommand="UPDATE [Notes] SET [DealID] = @DealID, [login] = @login, [Note] = @Note WHERE [NoteID] = @NoteID">
<asp:Parameter Name="NoteID" Type="Int32" />
<asp:Parameter Name="DealID" Type="Decimal" />
<asp:Parameter Name="login" Type="String" />
<asp:Parameter Name="Note" Type="String" />
<asp:Parameter Name="NoteID" Type="Int32" />
<asp:ControlParameter ControlID="DetailsView1" Name="DealID" PropertyName="SelectedValue"
Type="Decimal" />
<asp:Parameter Name="DealID" Type="Decimal" />
<asp:Parameter Name="login" Type="String" />
<asp:Parameter Name="Note" Type="String" />
Dec 11 '07 #1
0 3978

Sign in to post your reply or Sign up for a free account.

Similar topics

by: george | last post by:
This is like the bug from hell. It is kind of hard to explain, so please bear with me. Background Info: SQL Server 7.0, on an NT box, Active Server pages with Javascript, using ADO objects. ...
by: Mike | last post by:
I know this sounds strange but I am at a loss. I am calling a simple funtion that opens a connection to a SQL Server 2000 database and executes an Insert Statement. private void...
by: | last post by:
Hello, Does anyone have an idea on how I can filter the data in the gridview control that was returned by an sql query? I have a gridview that works fine when I populate it with data. Now I...
by: JayD | last post by:
Here is the problem: Using asp.net 2.0 to create a web app with standard master table gridview and child detailsview with insert capability. SQL Server 2000 database on the backend. Using Visual...
by: Greg Lyles | last post by:
Hi all, I'm trying to develop an ASP.NET 2.0 website and am running into some real problems with what I thought would be a relatively simple thing to do. In a nutshell, I'm stuck on trying to...
by: =?Utf-8?B?SGFycnkgS2Vjaw==?= | last post by:
I have a GridView that I dynamically add columns to in code. The way that my code is written, everything works properly if I use GridView.Columns.Add to simply add the columns to the end of the...
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList is...
by: Anilsg | last post by:
Hi all, I have the DropDownList in the FormView,inside InsertTemplateField The data is binded in run time to it in codebehind page,FOr the First time the page is loaded the DropdownList...
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.