Hello,I am trying to determine the best way to do the following. For simplicity we have two tables Master and Awards. These share a common pk UFID. Master contains columns (UFID, AccountName...) Awards contains columns (ID, UFID, AwardingAgency, Amount) When a user submits a new award in Formview I would like to populate the UFID automatically so that the user does not have to enter this each time. I am currently using the logged in username to select records for that user only. The value of this username matches Master.AccountName. Since I am hoping to use this same logic across many tables, I would appreciate any suggestions as to how best handle this.Thanks,Ken
I m trying to INSERT a record to my Consultants table using sqldatasource and formview: here is my sqldatasource code: <asp:SqlDataSource ID="sqlDS1" runat="server" ConnectionString="<%$ ConnectionStrings:myDB %>"InsertCommand="INSERT INTO [Consultants] ([firstName],[lastName],[skillCategoryID],[resourceManagerID],[AMgroupID],[skillSet],[statusID],[location],[comments],[profile],[isAvailable],[dateModified],[focusID]) VALUES (@FNAME, @LASTNAME, 1, @RESOURCEMANAGERID, @AMGROUPID, @SKILLSET, @STATUSID, @LOCATION,@COMMENTS,@PROFILE,@ISAVAILABLE,getdate(),1)">
<InsertParameters> <asp:FormParameter FormField="txtFName" Name="FNAME" /> <%--other parameters--%></InsertParameters></asp:SqlDataSource> now in my formview i have this:<asp:FormView DefaultMode="Insert" ID="FormView1" runat="server" DataSourceID="sqlDS1" DataKeyNames="id"> <table border="0" cellspacing="5" cellpadding="0"><tr> <td class="blacktextbold">First Name:</td> <td class="blacktext"><asp:TextBox ID="txtFName" CssClass="txtfield" Width="200" runat="server" Text="<% #Bind('firstName')%>" /> <asp:RequiredFieldValidator ControlToValidate="txtFName" runat="server" ValidationGroup="gpInsert" ErrorMessage="Required Field" Display="Dynamic" CssClass="redtextsmallbold" /> </td></tr> </table> THE PROBLEM:no matter what i put the txtFName field its ALWAYS null and i get INSERT error as column firstName cant accept NULLany ideas? ur help would be appreciated
I have a formview that uses a predefined dataset based on a cross table query. When the formview is in insert mode I need to insert the data into two seperate tables. Essentially I have tblPerson and tblAddress and my formview is capturing username, password, name, address line1, address line 2, etc. I presume I need to use a stored procedure to insert a row into tblPerson and then insert a row intp tblAddress. This is easy enough to do but the tables use RI and tblPerson has an imcremental primary key which needs to be innserted into a foreign key field in my address row. How do I do this? I'm using SQL Server.
I setup the databse and Visual Web Developer to use stored procedures when the insert command is used. The database also uses the field UserName that I pass using a SessionParameter within the InserParameter block from the Membership.GetUser.Username from the aspnet_ tables.
My difficulty is when using the "Formview" as the body to with which to insert (I wanted the design versatility of FormView) I get an error: "system.formatExpression: Input string was not in a correct format" when I leave the textboxes empty and invoke the insert command. I first assumed that the bound textboxes are not being converted correctly when left blank, so I used the ConvertEmptyStringToNull=True, with no success. I then coupled that with the Type=[correct format] still with the same error. Alas, my final attempt was to set defaults in the "ALTER PROCEDURE" within the stored procedure itself.
Dear All, i have a SqlDataSource with a simple select command(e.g. "select a,b,c from foo"). The insert command is a stored procedure and takes less parameters than there are columns in select statement (e.g. "insertFoo(a char(10))"). When used in combination with form view, i get "Procedure or function insertFoo has too many arguments specified" error. It seems that form view always posts all columns as parameter collection (breakpoint in formview_inserting event shows this) to insert command. Am I doing something wrong or is this by design? Is the only solution to manualy tweak parameters in formview_inserting event? TIA Jernej
I have a form view that I am using to insert new data into a sql express database and would like to find a way to avoid attempting to insert a record if the key already exists. is there a way to do this with the formview insert command. Everything works great until I try to add a record with an already existing value in the unique key field, then it breaks.
I'm trying to get to grips with the formview control and have a problem regarding where an exception is raised if SQL server raises an error when an insert is taking place. I am new to both asp.net & c# I have put the following code in the SqlDataSource2_Inserted & Formview1_Inserted events as a way of determining where the exception is raised: if (e.ExceptionHandled){ string exceptionmessage = e.Exception.Message; lblStatus.Text = exceptionmessage;} These two events are the only one's that have the ExceptionHandled and Exception properties. I run the code with data that will raise a duplicate key error from SQL Server but the error is not being caught by either of these two handlers. All I get is a page that starts with Server Error in '/SourceCode' Application.
Violation of UNIQUE KEY constraint 'IX_reftblAntigens'. Cannot insert duplicate key in object 'reftblAntigens'.The statement has been terminated. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Violation of UNIQUE KEY constraint 'IX_reftblAntigens'. Cannot insert duplicate key in object 'reftblAntigens'.The statement has been terminated.... Is there somewhere else I should be looking to handle this sort of thing? I thought using the databound controls would make life easier but I'm actually finding it more of a pain than coding everything myself.
HiI'm using SQLDataSource declarative data access with stored procedures (Select, Insert, Update, Delete). I need to display ReadOnly, Insert or Edit FormView DefaultMode from my FormView depending on whether or not the authenticated UserId is present in the Select stored procedure reference table. The scenario - during registration the new registrant may or may not complete a data entry step. If not that user must enter data on the given form before other site related functions can be accessed. Additionally, once these values are entered they may need to be changed. Any ideas?Thanks a lot.John
How can I generate the following command with VB Code Behind in NET 2.0 and have a FormView access the command. The 4 and 20 below may be 3 and 100 and etc."SELECT * FROM [Solution] WHERE ([SolutionID] IN ('4', '20'))" The List is generated by two multiselect controls (ListBox and CheckBoxList) and a text box used to search a description field in VB code behind (ASPX.VB) This post is a summary of a previous post not responded to. Sincerely,Unhistoric
Hello all! I am kinda new to this ASP.NET world! I have a website that requires daily updates! initially i was updating my database (MSSQL) manually, but now after watching videos from viseo section of this site i thought it would be better if i use formview to update , delete or edit my data! It all worked fine for me on my local machine! but when i deployed it on my server. I was able to add new records but when i tried to update an existing record or delete some record i got this error message...
The text, ntext, and image data types cannot be compared or sorted, except when using IS NULL or LIKE operator.
Please i know this problem is perhaps because of a very little mistake i may have done but i am going nuts because of it! please tell me what i have done wrong!
I am working in ASP.Net2.0 and Sql server 2005.Using asp button(FormView) I am trying to insert the data from the form into the database and at the same time want to move on to another page indicating the succes of insertion.My code: <asp:Button ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert"Text="Submit" PostBackUrl="~/ClinicDownload.aspx"></asp:Button> It is moving on to another page, but no insertion is taking place. If I don't give the PostBackUrl then I can insert. I want to do both in one click....Hope someone can help me. Regardspreeshma
I have formview and I have a SqlDatasource for it.I have few textboxes in the edit mode and bind it to the data columns or fields in the database.If the data for all those fields have content in it, then it will update just fine. However, if one of the text field is null or empty, the formview can't be updated When i try to update with empty data in one textboxData field allows null value, and type are varchar.I am suspecting it's throwing an internal exception somewhere. However, since all the operations are handled by the asp.net. I have no idea what's going on internally. Does anyone have an idea what's causing this error and how to fix it?
Hi, I followed a msdn2 tutorial http://msdn2.microsoft.com/fr-fr/library/system.web.ui.webcontrols.formview(VS.80).aspx using a formview.I got one error when trying to update a field : System.Data.OracleClient.OracleException: ORA-01036: illegal variable name/numberHere is my DataBase definition :ColumnType Nullable Primary Key EMPLOYEE_IDNUMBER(6,0) No - 1 FIRST_NAMEVARCHAR2(20) Yes - - LAST_NAMEVARCHAR2(25) No - -If someone has already got this error before or see why it happen, i'll be very happy if he tell it to me why. Here is my aspx page code : <html xmlns="http://www.w3.org/1999/xhtml"><head><title>Titre Forview</title></head> <body> <form id="Form1" runat="server"> <h3>FormView Example</h3> <asp:FormView id="EmployeeFormView" datasourceid="EmployeeSource" allowpaging="false" datakeynames="Employee_ID" headertext="Employee Record" emptydatatext="No employees found." onitemupdating="EmployeeFormView_ItemUpdating" onmodechanging="EmployeeFormView_ModeChanging" runat="server"> <headerstyle backcolor="CornFlowerBlue" forecolor="White" font-size="14" horizontalalign="Center" wrap="false"/> <rowstyle backcolor="LightBlue" wrap="false"/> <pagerstyle backcolor="CornFlowerBlue"/> <itemtemplate> <table> <tr><td rowspan="6"></td> <td colspan="2"></td> </tr> <tr><td><b>Name:</b></td> <td><%# Eval("First_Name") %> <%# Eval("Last_Name") %></td> </tr> <tr><td><b>Employee_ID:</b></td> <td><%# Eval("Employee_ID") %></td> </tr> <tr><td><b>Hire Date:</b></td> <td><%# Eval("Hire_Date","{0:d}") %></td> </tr> <tr><td></td><td></td></tr> <tr><td colspan="2"> <asp:linkbutton id="Edit" text="Edit" commandname="Edit" runat="server"/></td> </tr> </table> </itemtemplate> <edititemtemplate> <table> <tr><td rowspan="6"></td> <td colspan="2"></td> </tr> <tr><td><b>Name:</b></td> <td><asp:textbox id="FirstNameUpdateTextBox" text='<%# Bind("First_Name") %>' runat="server"/> <asp:textbox id="LastNameUpdateTextBox" text='<%# Bind("Last_Name") %>' runat="server"/></td> </tr> <tr><td></td><td></td></tr> <tr><td><b>Hire Date:</b></td><td> <asp:textbox id="HireDateUpdateTextBox" text='<%# Bind("Hire_Date", "{0:d}") %>' runat="server"/> </td> </tr> <tr valign="top"><td></td><td></td></tr> <tr> <td colspan="2"> <asp:linkbutton id="UpdateButton" text="UPDATE" commandname="Update" runat="server"/> <asp:linkbutton id="CancelButton" text="Cancel" commandname="Cancel" runat="server"/> </td> </tr> </table> </edititemtemplate> </asp:FormView> <asp:label id="MessageLabel" forecolor="Red" runat="server"/> <asp:sqldatasource id="EmployeeSource" selectcommand="Select Employee_ID, Last_Name, First_Name, Hire_Date From Employees where EMPLOYEE_ID=99" updatecommand="update EMPLOYEES set LAST_NAME='Last_Name', FIRST_NAME='First_Name' where EMPLOYEE_ID=99" ConnectionString="<%$ ConnectionStrings:ConnectionStringOracle %>" ProviderName="<%$ ConnectionStrings:ConnectionStringOracle.ProviderName %>" runat="server"/> </form> </body></html> And my aspx.cs page code : using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;using System.Collections.Specialized;using System.Data.OracleClient;using System.Windows.Forms;public partial class A_Supprimer_Aussi : System.Web.UI.Page{ protected void Page_Load(object sender, EventArgs e) { } public void EmployeeFormView_ItemUpdating(Object sender, FormViewUpdateEventArgs e) { // Validate the field values entered by the user. This // example determines whether the user left any fields // empty. Use the NewValues property to access the new // values entered by the user. ArrayList emptyFieldList = ValidateFields(e.NewValues);
if (emptyFieldList.Count > 0) { // The user left some fields empty. Display an error message. // Use the Keys property to retrieve the key field value. String keyValue = e.Keys["EmployeeID"].ToString(); MessageLabel.Text = "You must enter a value for each field of record " + keyValue + ".<br/>The following fields are missing:<br/><br/>"; // Display the missing fields. foreach (String value in emptyFieldList) { // Use the OldValues property to access the original value // of a field. MessageLabel.Text += value + " - Original Value = " + e.OldValues[value].ToString() + "<br>"; } // Cancel the update operation. e.Cancel = true; } else { // The field values passed validation. Clear the // error message label. MessageLabel.Text = ""; } } ArrayList ValidateFields(IOrderedDictionary list) { // Create an ArrayList object to store the // names of any empty fields. ArrayList emptyFieldList = new ArrayList(); // Iterate though the field values entered by // the user and check for an empty field. Empty // fields contain a null value. foreach (DictionaryEntry entry in list) { if (entry.Value == String.Empty) { // Add the field name to the ArrayList object. emptyFieldList.Add(entry.Key.ToString()); } }
return emptyFieldList; } public void EmployeeFormView_ModeChanging(Object sender, FormViewModeEventArgs e) { if (e.CancelingEdit) { // The user canceled the update operation. // Clear the error message label. MessageLabel.Text = ""; } }}
Hello,I have a formview and when I load it I would like to check a variable "Cover" from the database, to see wether or not it is empty. But how on earth do I get the variables from the sqldatasource in my function "FormView1_load(...)" ??
I've built a custom web-based CRM in ASP.NET 2.0 on Sql Server 2000. Currently updating a contact is very inconsistent. If I go into a contact through http://MyServer/secure/allcontacts.aspx or http://MyServer/secure/allcontacts.aspx?contactid=6151 then the updatecontact() sub that I have defined runs fine. UpdateContact() consists of a sql server transaction with a try/catch block and parameters for each field on the page. If I go through http://MyServer/secure/allcontacts.aspx?contactid=6151&Dup=true then I get "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding," on the catch section but no error message is rendered to the user - they see nothing at all. This seems to be happening when the application tries to access a formview control (which may or may not be visible at the time). I've tried Data.SqlClient.SqlConnection.ClearAllPools(), myCommand.CommandTimeout = 3000, and <httpRuntime executionTimeout="180"/> in the web.config but none of these seems to be working. The formview has a sql datasource and it gets as far as running the sqldatasource_selecting event and then gets stuck. Can anyone help me figure out why this is happening and how I can fix it? Thanks in advance.
Hi Folks, Somehow i am stuck at a very basic step. I have two pages - 1. DomainList.aspx which just displays all the records from the Domains table.2. DomainAddEdit.aspx which displays the selected record in FormView(Edit Mode) with two link for Update and Cancel. The Update link in the FormView does nothing on the first click. It just reloads the page with the new data I entered. If I click again on the Update link, it throws me an error: "Cannot insert the value NULL into column 'DNS', table 'MSInteractive.dbo.Domains'; column does not allow nulls. UPDATE fails.The statement has been terminated. " I have no clue why all this is happening. I have spent more than two days on this and this is very very frustrating. Just to mention, I haven't written any code for this. Its developed all using the VWD tools available. I have posted this message earlier but haven't got any response. I am sure most of you guys must have been doing these steps everyday. So, please post your thoughts. Thanks a million. Here is the relevant code for my DomainADDEdit.aspx: <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Edit"> <EditItemTemplate> Id: <asp:TextBox ID="IdTextBox" runat="server" Text='<%# Bind("Id") %>'></asp:TextBox><br /> RegistrarAccountId: <asp:TextBox ID="RegistrarAccountIdTextBox" runat="server" Text='<%# Bind("RegistrarAccountId") %>'></asp:TextBox><br /> Registrar: <asp:TextBox ID="RegistrarTextBox" runat="server" Text='<%# Bind("Registrar") %>'></asp:TextBox><br /> DNS: <asp:TextBox ID="DNSTextBox" runat="server" AutoPostBack="True" OnTextChanged="DNSTextBox_TextChanged" Text='<%# Bind("DNS") %>'></asp:TextBox><br /> EmailHost: <asp:TextBox ID="EmailHostTextBox" runat="server" Text='<%# Bind("EmailHost") %>'></asp:TextBox><br /> Registered: <asp:TextBox ID="RegisteredTextBox" runat="server" Text='<%# Bind("Registered") %>'></asp:TextBox><br /> Expires: <asp:TextBox ID="ExpiresTextBox" runat="server" Text='<%# Bind("Expires") %>'></asp:TextBox><br /> MsiResponsible: <asp:CheckBox ID="MsiResponsibleCheckBox" runat="server" Checked='<%# Bind("MsiResponsible") %>' /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MSInteractiveConnectionString %>" SelectCommand="SELECT [Id], [RegistrarAccountId], [Registrar], [DNS], [EmailHost], [Registered], [Expires], [MsiResponsible] FROM [Domains] WHERE ([Id] = @Id)" UpdateCommand="UPDATE Domains SET DNS = @txtDNS WHERE (Id = @Id)"> <UpdateParameters> <asp:FormParameter FormField="DNSTextBox" Name="txtDNS" /> <asp:QueryStringParameter Name="Id" QueryStringField="Id" /> </UpdateParameters> <SelectParameters> <asp:QueryStringParameter Name="Id" QueryStringField="Id" Type="String" /> </SelectParameters> </asp:SqlDataSource><br /> <asp:LinkButton ID="UpdateButton" runat="server" CommandName="Update" Text="Update" OnClick="UpdateButton_Click"></asp:LinkButton> <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"></asp:LinkButton> </EditItemTemplate>
Hi everyone, I'm in a scenario where I am using a FormView control to edit records. The data access is being done with an associated SqlDataSource control. The pipeline I use is usually setup using this pattern: (1) SqlDataSource.OnInserting -> (2) SqlDataSource.OnInserted -> (3) FormView.OnItemInserted The SqlDataSource events expose a SqlDataSourceCommandEventArg parameter that is much like a DbCommand object where you can start a transaction and associate other command objects with the command flowing through the pipeline. My question is does asp.net automatically dispose of the SqlDataSourceCommandEventArg command or must I do it manually? I assumed that after the SqlDataSource.OnInserted event the object would be disposed. If anyone has articles on this or any insight would be appreciated. Thanks
I have a formview with name, email, and password. I bind all fields to sql except the password which is blank. In my sqldatasource, I define parameters for name, email and id: UpdateCommand="UPDATE UserProfile SET Name = @Name,Email = @Email WHERE (ID = @ID)"><UpdateParameters><asp:Parameter Name="Name" /><asp:Parameter Name="Email" /><asp:Parameter Name="ID" /></UpdateParameters> In code I want to add a password parameter if there is value in the password field otherwise I don't want the password field updated. If I add define a password parameter like above then if a user left the password field blank then their new is blank. That's way I think adding it dynamically is the way. But I am having problems with the code to add the parameter in sqldatasource_updating event. Protected Sub SqlProfile_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlProfile.UpdatingDim password As TextBox = FormView1.FindControl Protected Sub SqlProfile_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlProfile.Updating Dim password As TextBox = FormView1.FindControl("tb_password1") If Not password.Text.ToString & "" = "" Then SqlProfile.UpdateParameters.Add(New Parameter("@Password", TypeCode.String, password.Text.ToString)) End If
I am trying to use the code below to set a formview datasource parameter in the page_load section of a user control (ascx file): public void Page_Load(object sender, EventArgs e){ formview_datasource.SelectParameters.Add("@department_id", "e62bbc7d623f44a68e101cba90e839s3");} However I am getting the following error: Exception Details: System.Data.SqlClient.SqlException: Must declare the variable '@department_id'. So it would seem that page_load in my user control isn't being called? I'm not sure why or how to work around it. Has anyone else experienced anything like this or can give me some pointers on where I am going wrong? ThanksBrad
Using formview control, I'm trying to insert a record. In the process of inserting, I want to save the categoryid from a shared class. The code runs fine but categoryid gets saved as null...Any pointers?? [When I display, it shows the value] thanks
protected void savebutton_click(object sender, EventArgs e) { //this statement runs fine under debug...but values do not get saved??? SqlDataSource1.InsertParameters.Add("@category", SharedValues.category.ToString()); SqlDataSource1.Insert(); }
Hi, I have a master/detail scenario whereby to populate a formview, the user selects a row in the gridview. The SqlDataSource used to populate the formview needs to check 2 columns from the gridview, ZRef (which is the SelectedValue of the Gridview) and ZName (a string). From searching the forums it looks like I have to programmatically assign the SelectParameters in order to get ZName from the gridview. Seems fair enough, so I set the parameters in the 'Selecting' event of the SqlDataSource. (Code shown below). However the formview never shows. In debug I can see that the values I'm setting in the SelectParameters.Add are correct; and if I set the default values for those parameters in the SqlDataSource itself, everything works fine. Can anyone point me to some sample VB code that does this - I'm sure this must be a common situation. Thanks. Protected Sub sdsOff_Selecting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Dim tmpSDS As SqlDataSource Dim tmpLBL As Label tmpSDS = CType(FormView1.FindControl("sdsOff"), SqlDataSource) If tmpSDS Is Nothing Then Server.Transfer("ErrorOnPage.htm") End If tmpLBL = Me.GridView1.Rows(GridView1.SelectedIndex).FindControl("lblName") If tmpLBL Is Nothing Then Server.Transfer("ErrorOnPage.htm") End If tmpSDS.SelectParameters.Clear() tmpSDS.SelectParameters.Add("ZRef", GridView1.SelectedValue) 'In debug, this shows 7 - which is correct tmpSDS.SelectParameters.Add("ZName", tmpLBL.Text) 'In debug, this shows 'Fred Bloggs' - which is correct End Sub
Hello all,I'm kind of new to ASP.NET and I've hit my first unsolvable roadblock. I'm trying to create a formview insertcommand that allows me to place the current date into a DateTime field but I continuously get an Input string was not in a correct format error. I may be using the wrong functions, I'm unsure. I've messed with DateTime.Now.ToString() as well as GETDATE() but I have no idea how to get it to work. I've also tried to switch the variable type of the field to a String type as well as DateTime. I am running visual basic .net with Microsoft SQL Server 2005. Here is my code right now: Experiencing problems with technology? Just fill out the form below and your problem will be forwarded to the Information Technology department.</em></strong><br /> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:TechticketdbConnectionString %>" SelectCommand="SELECT [CRDL#] AS column1, [Employee ID] AS Employee_ID, [Problem description] AS Problem_description, [Date submitted] AS Date_submitted, [Ticket number] AS Ticket_number FROM [Tickets]" DeleteCommand="DELETE FROM [Tickets] WHERE [Ticket number] = @Ticket_number" InsertCommand="INSERT INTO [Tickets] ([CRDL#], [Employee ID], [Problem description], [Date submitted]) VALUES (@column1, @Employee_ID, @Problem_description, GETDATE() )" UpdateCommand="UPDATE [Tickets] SET [CRDL#] = @column1, [Employee ID] = @Employee_ID, [Problem description] = @Problem_description, [Date submitted] = @Date_submitted WHERE [Ticket number] = @Ticket_number"> <DeleteParameters> <asp:Parameter Name="Ticket_number" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="column1" Type="Int32" /> <asp:Parameter Name="Employee_ID" Type="Int32" /> <asp:Parameter Name="Problem_description" Type="String" /> <asp:Parameter Name="Date_submitted" Type="String" /> <asp:Parameter Name="Ticket_number" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="column1" Type="Int32" /> <asp:Parameter Name="Employee_ID" Type="Int32" /> <asp:Parameter Name="Problem_description" Type="String" /> <asp:Parameter Name="Date_submitted" Type="String" /> </InsertParameters> </asp:SqlDataSource> I've left out the EditItemTemplate because it isn't going to be used for this form. Here is the InsertItemTemplate: <InsertItemTemplate> column1: <asp:TextBox ID="column1TextBox" runat="server" Text='<%# Bind("column1") %>'> </asp:TextBox><br /> Employee_ID: <asp:TextBox ID="Employee_IDTextBox" runat="server" Text='<%# Bind("Employee_ID") %>'> </asp:TextBox><br /> Problem_description: <asp:TextBox ID="Problem_descriptionTextBox" runat="server" Text='<%# Bind("Problem_description") %>'> </asp:TextBox><br /> <asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert"> </asp:LinkButton> <asp:LinkButton ID="InsertCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"> </asp:LinkButton> </InsertItemTemplate> <ItemTemplate> column1: <asp:Label ID="column1Label" runat="server" Text='<%# Bind("column1") %>'></asp:Label><br /> Employee_ID: <asp:Label ID="Employee_IDLabel" runat="server" Text='<%# Bind("Employee_ID") %>'> </asp:Label><br /> Problem_description: <asp:Label ID="Problem_descriptionLabel" runat="server" Text='<%# Bind("Problem_description") %>'> </asp:Label><br /> Date_submitted: <asp:Label ID="Date_submittedLabel" runat="server" Text='<%# Bind("Date_submitted") %>'> </asp:Label><br /> Ticket_number: <asp:Label ID="Ticket_numberLabel" runat="server" Text='<%# Eval("Ticket_number") %>'> </asp:Label><br /> <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit" Text="Edit"> </asp:LinkButton> <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete"> </asp:LinkButton> <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New" Text="New"> </asp:LinkButton> </ItemTemplate> </asp:FormView> I would like to get the value formatted as a DateTime but a String will do just fine if a DateTime variable won't work. Any help would be greatly appreciated. Thanks!
Hi I am new to asp.net world. I have a page with two formviews bound to two sqldatsources. One datasource connects to sql database and other to access. The information from both the databases is quite similar. The default mode for formview1 is edittemplate and for formview2 it is itemtemplate. I want to give the user an option to update formview1 data based on information retrevied in formview2 on a click of a button. I want to do this in code behind .cs file. I am not sure how can I access the values from formview templates e.g formview1.itemtemplate... etc? Can anyone please suggest a way to acheive this? Thanks
Guys, here is my scenario: I have 3 tables 1) Vendor 2) Service 3) Service Product Each vendor has the ability to have any number of services, all with any number of service products. How should I setup my page so I can edit/insert vendors, and tie a list of service products and services to them? My plan was to have a Formview with either a checkboxlist, or multilist (to select multiple items - but they don't work that way) and then store selected items in another table (each item selected with its own record) to hold onto the vendor id and tie it to a service id and a product id, but I was unsure how to do this. Any help would be greatly appreciated. FYI I am writing in VB.
I am trying to return the ID of the last record entered into my database so the user will have his Record ID. I'm trying to do this in a from view. text='<%#eval("ID")%>' SelectCommand="SELECT MAX(ID) FROM [Webenhancetest]"> If it is done in this manner, it says DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'MAX'. and if I just use SELECT IDFROM [Webenhancetest it works but only returns the first record which is 1.
We got a problem with sql sever in vwd 2008 express.
Q1: is it possible to use an "image button" as an "insert button"?
Q2: Do you have to put the "insert button" in the same table as the "binded" variables for the textbox fields?
In the code we tried to position the "insert button" att three different locations but only one worked. At LOCATION 1 all fields except "presentation" were saved to the database.
At LOCATION 2 the "image button" skips saving the fields.
At LOCATION 3 we get an error msg: [SqlException (0x80131904): Måste deklarera den skalära variabeln "@arbetstakt".] (in english: must declare the ?scalar? variable...)
Hi, My formview or gridview control stops updating or deleting a record once the record has a null value. I have table tblTest with the following pkID int NOT NULL **IDENTITY COLUMN** string1 varchar(30) string2 varchar(30) I then create a SqlDataSource with the statement: Select * From [tblTest] I have the insert, update and delete statements generated, and choose optimistic concurrency. I add a couple records of dummy data. I then drag a Formview control onto the page, and bind it to the SqlDataSource I just created. I then fire it up in my browser, and I can then update, insert and delete records. However, as soon as I update a record with a null value, I can no longer update or delete that record. So, if I had a record in my FormView like: string1: foo string2: bar I can update and delete normally. And when I update to: string1: foo string2: the database correctly inserts a null value into string2. However, once that null is in the record, I can't change anything about the record. If I try to delete the record, the FormView will then display the previous record, but I can still page to the record that should have been deleted, and it still exists in the db. If I try to update the record, the edits I make will not keep and the process will fail silently. What am I doing wrong? Should i be binding to a different object? Regards, Chris
Using 3.5 If I have a sqldatasource on the page, is it run if it is not bound to a data object like a gridview? Seems like if i want to access the data (like set a label text) from the sqldatasource I have to use code to first create a dataview then pick throught it. This seems like I'm running it twice. I'm new at .net so I dont know how to tell. I don't want to write data select code programatically when I can just through an SDS on the page, but wondered it it ran just because it's on the page.
Please excuse me if this question has been asked before; I couldn’t find it. Perhaps someone could point me to the solution. A few years ago I wrote an order-entry application in classic ASP that I am now re-writing in ASP.NET 2.0. I am having very good success however I can’t figure out how to retrieve data from a stored procedure. I am using the FormView & SqlDataSource controls with a stored procedure to insert items into an order. Every time an item is inserted into the order the stored procedure does all kinds of business logic to figure out if the order qualifies for pricing promotions, free shipping, etc. If something happens that the user needs to know about the stored procedure returns a message with this line (last line in the SP) SELECT @MessageCode AS MessageCode, @MessageText AS MessageText I need to retrieve both the @MessageCode and the @MessageText values in my application. In classic ASP I retrieved these values by executing the SP with a MyRecordset.Open() and accessing them as normal fields in the recordset. In ASP.NET I have specified the SP as the InsertCommand for the SqlDataSource control. I have supplied all the parameters required by my SP and told the SqlDataSource that the insert command is a “StoredProcedure�. Everything actuly works just fine. The items are added to the order and the business logic in the SP works fine. I just have no way of telling the user that something important has happened. Does anyone know how I can pickup these values so that I can show them to my users? Bassicly if @MessageCode <> 0 I want to show @MessageText on the screen.
Follow-up to: http://forums.asp.net/t/1237676.aspx The update command seems to be deleting my data. If I set the Parameter "DefaultValue" to "NULL" then it updates that field to the literal string: NULL WTH Nick <UpdateParameters> <asp:Parameter Name="DevelopmentArea" Type="String"/> <asp:Parameter Name="DevelopmentGoals" Type="String" /> <asp:Parameter Name="DevelopmentPlans" Type="String" /> <asp:Parameter Name="CurrentStatus" Type="String" /> <asp:Parameter Name="FutureState" Type="String" /> <asp:Parameter Name="DetermineFactor" Type="String"/> <asp:Parameter Name="MentorRequested" Type="Boolean" DefaultValue="False"/> <asp:Parameter Name="MentorList" Type="String"/> <asp:Parameter Name="CheckPointDate" Type="DateTime" /> <asp:Parameter Name="DateUpdated" Type="DateTime" /> <asp:Parameter Name="PlanPKID" Type="Int32" /> </UpdateParameters>
How do I post the currentdatetime (now) into a DateTime field in SQLserver using a formview? I tried a couple different techniques, but had problems with both: 1. TRY ONE: I created a date time field on the SQL server named entrydate. I can not figure out how to post the current datetime into it, without the user inputting it into a field.
2. Second TRY: I tried to change the datetime field on the sql server to a datetime stamp field, but it puts in a binary value. Then I can't read it correctly, and my delete functions don't work.