Can You Have A FormView Use SELECT FROM WHERE IN?

Mar 4, 2007

 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 

View 2 Replies


ADVERTISEMENT

Sqldatasource, Does It Select If Not Bound To A Gridview, Formview On The Page?

Feb 22, 2008

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.

View 2 Replies View Related

FormView DefaultMode

Nov 29, 2006

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
 

View 2 Replies View Related

FormView Problem! PLease Help!

Jun 14, 2008

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.
 
This is my coding
 
<form id="form1" runat="server">    <div style="text-align: center">        <div style="text-align: center">            <table>                <tr>                    <td style="width: 100px">                        <asp:FormView ID="FormView1" runat="server" AllowPaging="True" CellPadding="4" DataKeyNames="id"                            DataSourceID="SqlDataSource1" ForeColor="#333333" Height="290px" Width="329px">                            <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />                            <EditRowStyle BackColor="#999999" />                            <EditItemTemplate>                                id:                                <asp:Label ID="idLabel1" runat="server" Text='<%# Eval("id") %>'></asp:Label><br />                                title:                                <asp:TextBox ID="titleTextBox" runat="server" Text='<%# Bind("title") %>'>                                </asp:TextBox><br />                                url:                                <asp:TextBox ID="urlTextBox" runat="server" Text='<%# Bind("url") %>'>                                </asp:TextBox><br />                                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"                                    Text="Update">                                </asp:LinkButton>                                <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"                                    Text="Cancel">                                </asp:LinkButton>                            </EditItemTemplate>                            <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />                            <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />                            <InsertItemTemplate>                                <asp:TextBox ID="idTextBox" runat="server" Text='<%# Bind("id") %>'></asp:TextBox><br />                                title:                                <asp:TextBox ID="titleTextBox" runat="server" Text='<%# Bind("title") %>'></asp:TextBox><br />                                url:                                <asp:TextBox ID="urlTextBox" runat="server" Text='<%# Bind("url") %>'></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>                                <span style="font-size: 24pt">id: </span>                                <asp:Label ID="idLabel" runat="server" Text='<%# Eval("id") %>' Width="119px"></asp:Label><br />                                <span style="font-size: 24pt">title: </span>                                <asp:Label ID="titleLabel" runat="server" Text='<%# Bind("title") %>' Width="111px"></asp:Label><br />                                <span style="font-size: 24pt">url: </span>                                <asp:Label ID="urlLabel" runat="server" Text='<%# Bind("url") %>' Width="105px"></asp:Label><br />                                <asp:LinkButton ID="EditButton" runat="server" CausesValidation="False" CommandName="Edit"                                    Text="Edit"></asp:LinkButton><span style="font-size: 24pt"> </span>                                <asp:LinkButton ID="DeleteButton" runat="server" CausesValidation="False" CommandName="Delete"                                    Text="Delete"></asp:LinkButton><span style="font-size: 24pt"> </span>                                <asp:LinkButton ID="NewButton" runat="server" CausesValidation="False" CommandName="New"                                    Text="New"></asp:LinkButton><span style="font-size: 24pt"> </span>                            </ItemTemplate>                            <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />                        </asp:FormView>                        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"                            ConnectionString="<%$ ConnectionStrings:ConnectionString %>" DeleteCommand="DELETE FROM [homelinks] WHERE [id] = @original_id AND [title] = @original_title AND [url] = @original_url"                            InsertCommand="INSERT INTO [homelinks] ([id], [title], [url]) VALUES (@id, @title, @url)"                            OldValuesParameterFormatString="original_{0}" SelectCommand="SELECT * FROM [homelinks] ORDER BY [id] DESC"                            UpdateCommand="UPDATE [homelinks] SET [title] = @title, [url] = @url WHERE [id] = @original_id AND [title] = @original_title AND [url] = @original_url">                            <DeleteParameters>                                <asp:Parameter Name="original_id" Type="Int32" />                                <asp:Parameter Name="original_title" Type="String" />                                <asp:Parameter Name="original_url" Type="String" />                            </DeleteParameters>                            <UpdateParameters>                                <asp:Parameter Name="title" Type="String" />                                <asp:Parameter Name="url" Type="String" />                                <asp:Parameter Name="original_id" Type="Int32" />                                <asp:Parameter Name="original_title" Type="String" />                                <asp:Parameter Name="original_url" Type="String" />                            </UpdateParameters>                            <InsertParameters>                                <asp:Parameter Name="id" Type="Int32" />                                <asp:Parameter Name="title" Type="String" />                                <asp:Parameter Name="url" Type="String" />                            </InsertParameters>                        </asp:SqlDataSource>                    </td>                </tr>                <tr>                    <td style="width: 100px">                    </td>                </tr>                <tr>                    <td style="width: 100px">                    </td>                </tr>            </table>        </div>        </div>    </form>
 
 
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!
 
 

View 2 Replies View Related

Formview Insertion And PostBackUrl

Sep 13, 2006

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 

View 1 Replies View Related

Formview Doesn't Update

Dec 13, 2006

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?  

View 2 Replies View Related

How Get The New Recorde ID After Formview Insert

Mar 19, 2007

I have formview and want to get uniq id from SQL Server 2005 after it inserted.
I think i should put some code in the event of oniteminserted, anybody have sample code
Thanks
Hu 

View 1 Replies View Related

Update From A FormView To An Oracle DB

Jul 23, 2007

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() + "&lt;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 = ""; } }}   

View 1 Replies View Related

FormView Insert Query

Apr 22, 2008

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 

View 1 Replies View Related

Get A Variable From Db When A FormView Loads

Apr 21, 2006

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(...)" ??

View 1 Replies View Related

Formview Does Not Update Database

May 21, 2006

HiI'm using a FormView to allow my administrator to add/edit/remove questions/answers to the FAQ of my helpdesk.Now I figured out how to use the FormView to adjust the data, the only thing the FormView does NOT do, is actually update the database, it does not give any errors, it just doesn't do anything.This is the code:  <asp:SqlDataSource ID="sdsAdminFaqDetails" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
DeleteCommand="DELETE FROM [Faq] WHERE [QuestionID] = @QuestionID"
InsertCommand="INSERT INTO [Faq] ([Question], [Answer]) VALUES (@Question, @Answer)"
SelectCommand="SELECT * FROM [Faq]"
UpdateCommand="UPDATE [Faq] SET [Question] = @Question, [Answer] = @Answer WHERE [QuestionID] = @QuestionID">
<DeleteParameters>
<asp:Parameter Name="QuestionID" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="Question" />
<asp:Parameter Name="Answer" />
<asp:Parameter Name="QuestionID" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="Question" />
<asp:Parameter Name="Answer" />
</InsertParameters>
</asp:SqlDataSource>
<asp:FormView ID="FormView1" runat="server" DataSourceID="sdsAdminFaqDetails">
<ItemTemplate>
<table border="0">
<tr>
<td style="width: 189px"><asp:Label ID="lblQuestionLabel" runat="server" Text="Vraag:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px"><asp:TextBox ReadOnly="True" ID="txtQuestion" runat="server" Text='<%# Eval("Question") %>' Width="309px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 189px"><asp:Label ID="lblAnswerLabel" runat="server" Text="Antwoord:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px; height: 40px"><asp:TextBox ReadOnly="True" ID="txtAnswer" runat="server" Text='<%# Eval("Answer") %>' Height="160px" TextMode="MultiLine" Width="457px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnEdit" runat="server" Text="Wijzig" CommandName="Edit" /> <asp:Button ID="btnInsert" runat="server" Text="Nieuw" CommandName="New" /></td>
</tr>
</table>
</ItemTemplate>
<EditItemTemplate>
<table border="0">
<tr>
<td style="width: 189px"><asp:Label ID="lblQuestionLabel" runat="server" Text="Vraag:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px"><asp:TextBox ID="txtQuestion" runat="server" Text='<%# Bind("Question") %>' Width="309px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 189px"><asp:Label ID="lblAnswerLabel" runat="server" Text="Antwoord:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px; height: 40px"><asp:TextBox ID="txtAnswer" runat="server" Text='<%# Bind("Answer") %>' Height="160px" TextMode="MultiLine" Width="457px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnUpdate" runat="server" Text="Bevestig" CommandName="Update" /> <asp:Button ID="btnDelete" runat="server" Text="Verwijder" CommandName="Delete" /></td>
</tr>
</table>
</EditItemTemplate>
<InsertItemTemplate>
<table border="0">
<tr>
<td style="width: 189px"><asp:Label ID="lblQuestionLabel" runat="server" Text="Vraag:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px"><asp:TextBox ID="txtQuestion" runat="server" Width="309px"></asp:TextBox></td>
</tr>
<tr>
<td style="width: 189px"><asp:Label ID="lblAnswerLabel" runat="server" Text="Antwoord:"></asp:Label></td>
</tr>
<tr>
<td style="width: 189px; height: 40px"><asp:TextBox ID="txtAnswer" runat="server" Height="160px" TextMode="MultiLine" Width="457px"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnInsert" runat="server" Text="Voeg toe" CommandName="Insert" /> <asp:Button ID="btnCancel" runat="server" Text="Annuleer" CommandName="Cancel" /></td>
</tr>
</table>
</InsertItemTemplate>
<EmptyDataTemplate>
U hebt niet geselecteerd welke vraag u wilt wijzigen.
</EmptyDataTemplate>
</asp:FormView>
hope one of you sees where i made a mistake, or forgot about something...thx for your help

View 12 Replies View Related

Server Timeout Accessing A Formview

Jul 10, 2006

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.

View 4 Replies View Related

Sqldatasource And Formview Insert Problem

Aug 10, 2006

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
 

View 4 Replies View Related

Need Help With Update Link In FormView - URGENT

Dec 7, 2006

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>
 

View 5 Replies View Related

FormView W/SqlDataSource - Auto Disposed?

Mar 17, 2007

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

View 3 Replies View Related

Dynamically Add Update Parameter To Formview

May 3, 2007

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

End Sub Thanks

View 9 Replies View Related

Setting Formview Datasource Parameter

May 23, 2007

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

View 3 Replies View Related

Question - Inserting With Formview Control

Nov 10, 2005

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();    }   
 
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="itemid" DefaultMode="edit" OnDataBound="FormView1_DataBound">    <EditItemTemplate>               Title:        <asp:TextBox ID="titleTextBox" runat="server" Text='<%# Bind("title") %>'>        </asp:TextBox><br/>        Description:        <asp:TextBox ID="descriptionTextBox" runat="server" Text='<%# Bind("description") %>' Rows="10" TextMode="MultiLine" Width="500px" Height="166px">        </asp:TextBox><br/>                      <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" CommandName="Update"            Text="Update">        </asp:LinkButton>        <asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel"            Text="Cancel">        </asp:LinkButton>            </EditItemTemplate>    <InsertItemTemplate>        Title:        <asp:TextBox ID="titleTextBox" runat="server" Text='<%# Bind("title") %>'>        </asp:TextBox><br/>        Description:        <asp:TextBox ID="descriptionTextBox" runat="server" Text='<%# Bind("description") %>' Rows="10" TextMode="MultiLine" Width="500px" Height="166px">        </asp:TextBox><br/>            <asp:label ID="categoryLbl" runat="server" Text='<%# SharedValues.category %>'></asp:label>        <br/>               <div class="actionbuttons">                        <Club:RolloverButton ID="GreenRolloverButton3" CommandName="Insert" Text="Save"                            runat="server" OnClick="savebutton_click" />                        <Club:RolloverLink ID="GreenRolloverLink2" Text="Cancel" runat="server" NavigateURL="Classifieds.aspx" />                    </div>    </InsertItemTemplate>   </asp:FormView><asp:SqlDataSource ID="SqlDataSource1"  runat="server" ConnectionString="<%$ ConnectionStrings:ClubSiteDB %>"     InsertCommand="insert into tads (title,[description], categoryid) values (@title,@description, @category)"     SelectCommand="Select title, [description], categoryid from tads where itemid=@itemid"     UpdateCommand="update tads set title = @title, [description] = @description where itemid = @itemid" >    <SelectParameters>        <asp:QueryStringParameter Name="itemid" QueryStringField="itemid" Type="Int32" />    </SelectParameters>    <UpdateParameters>        <asp:Parameter Name="title" Type="String" />        <asp:Parameter Name="description" Type="String" />    </UpdateParameters>    <InsertParameters>      <asp:Parameter Name="title" Type="String" />        <asp:Parameter Name="description" Type="String" />        <asp:Parameter Name="category" Type="Int32" />    </InsertParameters></asp:SqlDataSource>

View 1 Replies View Related

How Do I Populate A Formview From Multiple Columns In A Gridview

Jun 29, 2006

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
 

View 5 Replies View Related

Problem With Storing Datetime Values In Formview

Jan 20, 2007

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! 

View 2 Replies View Related

Updating Database In Cs File - Using Sqldatsource And Formview

Feb 8, 2007

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 
 
 
 
 

View 5 Replies View Related

Insert Two Rows Into Two Tables At The Same Time From A Formview

Jul 31, 2007

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. 

View 3 Replies View Related

Help With Logic - VB - Formview - Multiple Database Tables

Jan 4, 2008

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.

View 2 Replies View Related

Trying To Return MAX(value) Of A Database In Formview Text='&<%# Eval(MAX(ID1)) %&>

Mar 4, 2008

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.
 
How do I grab the last record, or Max(ID)???
 
 

View 2 Replies View Related

Sql Server 2005 With Default Formview Problem

Mar 19, 2008

Hi!

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...)


<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Tunnel1.aspx.vb" Inherits="Default2" title="Untitled Page" %>

<asp:Content ID="Main" ContentPlaceHolderID="Main" Runat="Server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

InsertCommand="INSERT INTO konsult(arbetstakt, typ, presentation, postadress, språk, postnr, CO, epost, mobil, telefon, enamn, fnamn, pnummer) VALUES (@arbetstakt, @typ, @presentation, @postadress, @språk, @postnr, @CO, @epost, @mobil, @telefon, @enamn, @fnamn, @pnummer)">
</asp:SqlDataSource>

<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Insert">
<InsertItemTemplate>

<table cellpadding="0" cellspacing="0" width="100%" border="0">
<!-- Menyrad -->
<tr>
<td colspan="2">
<table align="right" cellpadding="0" width="100%" bgcolor="#EEEEEE">
<tr>
<td align="left">
<script type="text/javascript" language="JavaScript">showMenus(1,'Horizontal')</script>
</td>
<td align="right">
<!-- <asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

InsertCommand="INSERT INTO konsult(arbetstakt, typ, postadress, språk, postnr, CO, epost, mobil, telefon, enamn, fnamn, pnummer) VALUES (@arbetstakt, @typ, @postadress, @språk, @postnr, @CO, @epost, @mobil, @telefon, @enamn, @fnamn, @pnummer)">
</asp:SqlDataSource> -->
<b>Steg 1</b> av 5: Personuppgifter  </td>

<td bgcolor="#EEEEEE" width="25" height="25" align="center">
<asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/Images/TunnelKnapp1vald.jpg" PostBackUrl="~/Tunnel1.aspx" AlternateText="Steg 1" />
</td>

<td bgcolor="#EEEEEE" width="25" height="25" align="center">
<asp:ImageButton ID="ImageButton2" runat="server"
ImageUrl="~/Images/TunnelKnapp2.jpg" PostBackUrl="~/Tunnel2.aspx" AlternateText="Steg 2"/>
</td>

<td bgcolor="#EEEEEE" width="25" height="25" align="center">
<asp:ImageButton ID="ImageButton3" runat="server"
ImageUrl="~/Images/TunnelKnapp3.jpg" PostBackUrl="~/Tunnel3.aspx" AlternateText="Steg 3"/>
</td>

<td bgcolor="#EEEEEE" width="25" height="25" align="center">
<asp:ImageButton ID="ImageButton4" runat="server"
ImageUrl="~/Images/TunnelKnapp4.jpg" PostBackUrl="~/Tunnel4.aspx" AlternateText="Steg 4" />
</td>

<td bgcolor="#EEEEEE" width="25" height="25" align="center">
<asp:ImageButton ID="ImageButton5" runat="server"
ImageUrl="~/Images/TunnelKnapp5.jpg" PostBackUrl="~/Tunnel5.aspx" AlternateText="Steg 5" />
</td>
</tr>
</table>
</td>
</tr>
<!-- Sidan -->
<tr>
<!-- Topp skuggor -->
<td width="500" height="15" style="background-image: url('Images/toppskugga_Liten.jpg'); background-repeat: no-repeat; background-position: center bottom">
<table cellpadding="0" cellspacing="0">
<tr>
<td width="20"></td>
<td width="460"></td>
<td width="20"></td>
</tr>
</table>
</td>
</tr>
<tr>
<!-- Mellan skuggor -->
<td width="500" style="background-image: url('Images/mellanskugga_Liten.jpg'); background-repeat: repeat-y; background-position: center bottom">
<table cellpadding="0" cellspacing="0">
<tr>
<td width="20"></td>
<td width="460">
<!-- <asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Insert">
<InsertItemTemplate> -->
<table width="100%">
<tr>
<td width="150">Personnummer:*</td>
<td width="250"><asp:TextBox Width="150" ID="pnummerTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("pnummer") %>' /></td>
</tr>
<tr>
<td width="150">Förnamn:*</td>
<td width="250"><asp:TextBox Width="150" ID="fnamnTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("fnamn") %>' /></td>
</tr>
<tr>
<td width="150">Efternamn:*</td>
<td width="250"><asp:TextBox Width="150" ID="enamnTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("enamn") %>' /></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td width="150">Telefon:</td>
<td width="250"><asp:TextBox Width="150" ID="telefonTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("telefon") %>' /></td>
</tr>
<tr>
<td width="150">Mobil:*</td>
<td width="250"><asp:TextBox Width="150" ID="mobilTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("mobil") %>' /></td>
</tr>
<tr>
<td width="150">Epost:*</td>
<td width="250"><asp:TextBox Width="150" ID="epostTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("epost") %>' /></td>
</tr>
<tr>
<td width="150">CO:</td>
<td width="250"><asp:TextBox Width="150" ID="COTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("CO") %>' /></td>
</tr>
<tr>
<td width="150">Postnummer:</td>
<td width="250"><asp:TextBox Width="150" ID="postnrTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("postnr") %>' /></td>
</tr>
<tr>
<td width="150">Postadress:</td>
<td width="250"><asp:TextBox Width="150" ID="postadressTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("postadress") %>' /></td>
</tr>
<tr><td><br></td></tr>
<tr>
<td width="150">Övrigt språk:</td>
<td width="250">
<asp:DropDownList Width="156" ID="språkDropDownList" runat="server" Font-Size="X-Small" Text='<%# Bind("språk") %>'>
<asp:ListItem>Välj språk</asp:ListItem>
<asp:ListItem>Engelska</asp:ListItem>
<asp:ListItem>Tyska</asp:ListItem>
<asp:ListItem>Ryska</asp:ListItem>
<asp:ListItem>Spanska</asp:ListItem>
<asp:ListItem>Franska</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td width="150">Konsulttyp:</td>
<td width="250">
<asp:DropDownList Width="156" ID="typDropDownList" runat="server" Font-Size="X-Small" Text='<%# Bind("typ") %>'>
<asp:ListItem>Intern</asp:ListItem>
<asp:ListItem>Extern</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td width="150">Arbetstakt:</td>
<td width="250">
<asp:DropDownList Width="156" ID="arbetstaktTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("arbetstakt") %>'>
<asp:ListItem>25%</asp:ListItem>
<asp:ListItem>50%</asp:ListItem>
<asp:ListItem>75%</asp:ListItem>
<asp:ListItem>100%</asp:ListItem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td align="right">
<!-- LOCATION 1
<asp:Button ID="InsertButton" CommandName="Insert" CausesValidation="True" runat="server" Text="Spara" /> -->
</td>
</tr>
</table>
<!-- </InsertItemTemplate>
</asp:FormView> -->
</td>
<td width="20"></td>
</tr>
</table>
</td>
<td rowspan="3" width="240" valign="top">
<table cellpadding="0" cellspacing="0">
<tr>
<td width="240" align="right">
<!-- <img src="Images/PilBak.jpg" alt="Bak"/> -->
 
<!-- LOCATION 2

<asp:ImageButton ID="InsertButton" CommandName="Insert" runat="server" CausesValidation="True" ImageUrl="Images/PilFram.jpg" PostBackUrl="Tunnel2.aspx" AlternateText="Fram" /> -->

 
</td>
</tr>
<tr>
<td width="240" style="background-image: url('Images/toppskugga_Mini.jpg'); background-repeat: repeat-y; background-position: center bottom"> </td>
</tr>
<tr>
<td width="240" style="background-image: url('Images/mellanskugga_Mini.jpg'); background-repeat: repeat-y; background-position: center bottom">
<table>
<tr>
<td width="20"></td>
<td width="200" valign="top" align="center">
<asp:Image ID="Image9" runat="server" width="150" Height="150"
ImageUrl="~/Images/defaultFoto.jpg"/>
<br />
<asp:Button ID="InsertButton2" runat="server" Text="Ladda upp bild" />
<br /><br />
Personlig beskrivning:
<br />
<!--<asp:FormView ID="FormView2" runat="server" DataSourceID="SqlDataSource1" DefaultMode="Insert">
<InsertItemTemplate>-->
<table cellpadding="0" cellspacing="4">
<tr>
<td>
<asp:TextBox ID="txtPersonligPresentation" Text='<%# Bind("presentation") %>' runat="server" Width="175" Rows="6" TextMode="MultiLine"></asp:TextBox>
</td>
<tr>
</tr>
<td align="right">
<!-- LOCATION 3 -->
<asp:Button ID="InsertButton" CommandName="Insert" CausesValidation="True" runat="server" Text="Spara" />
</td>
</tr>
</table>
<!-- </InsertItemTemplate>
</asp:FormView> -->
</td>
<td width="20"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="240" style="background-image: url('Images/bottenskugga_Mini.jpg'); background-repeat: repeat-y; background-position: center bottom"> </td>
</tr>
</table>
</td>
</tr>
<tr>
<!-- Botten skuggor -->
<td width="500" height="20" style="background-image: url('Images/bottenskugga_Liten.jpg'); background-repeat: no-repeat; background-position: center bottom">
<table cellpadding="0" cellspacing="0">
<tr>
<td width="20"></td>
<td width="460"></td>
<td width="20"></td>
</tr>
</table>
</td>
</tr>
</table>

</InsertItemTemplate>
</asp:FormView>
</asp:Content>



Is it possible to solve this?

View 1 Replies View Related

Issue Inserting Null Value Into A Formview/gridview Control

Jan 14, 2007

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

View 5 Replies View Related

Retrieving Values From Stored Procedure Using FormView && SqlDataSource

Mar 3, 2008

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.

View 10 Replies View Related

On Formview Clicking Update Causes Form Data To Disappear?!?

Mar 24, 2008

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>

View 6 Replies View Related

Having Difficulty With FormView, Stored Procedures And Insert Parameter

Feb 17, 2005

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.

Any help would be most appreciated. Thanks.
.

View 2 Replies View Related

SqlDataSource With Different Number Of Columns And Insert Parameters And FormView

Dec 7, 2005

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

View 2 Replies View Related

How Do I Post The Currentdatetime (now) Into A DateTime Field In SQLserver Using A Formview?

Feb 27, 2006

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.
 
Thanks Ed

View 2 Replies View Related

How To Pass The Value Of A Text Box Inside A FORMVIEW To A SQL Stored Procedure

May 28, 2006

Hi,
I'm new to ASP.NET 2.0. I have a sqldatasource and a formview controls on a web page and inside the formview control I have  two textboxes. When I click the UPDATE button in the formview, I'd like to be able to retrieve the values of the textboxes inside the formview control and pass these values to a 'Update' SQL stored procedure defined in the Sqldatasource.
Does anyone know how I can do this? Hope my question is clear.
Thanks in advance.
hakl

View 1 Replies View Related

FormView - Update Process Completes With No Error But Records Is Not Changed

Jul 24, 2006

Greetings,
I have setup a FormView which functions as it should but after the user input is updated, the table record stays unchanged, and when I trap the FormView1_ItemUpdated and look at the SqlDataSource1.UpdateCommand, it shows this:
UPDATE [aspnet_test] SET first_name = '', last_name = '', email = '' WHERE id = @original_ID
Here is most of the code I am using:<asp:FormView ID="FormView1" runat="server"   DataSourceID="SqlDataSource1" DataKeyNames="id, first_name, last_name"   OnItemUpdating="FormView1_ItemUpdating" OnItemUpdated="FormView1_ItemUpdated" > .. // my ItemEditTempate is here.</asp:FormView>
<EditItemTemplate>First Name: <asp:TextBox Text='<%# Bind("first_name") %>' runat="server" ID="author_name" Columns="20"></asp:TextBox><br />Last Name: <asp:TextBox Text='<%# Bind("last_name") %>' runat="server" ID="TextBox1" Columns="20"></asp:TextBox><br />E-mail: <asp:TextBox Text='<%# Bind("email") %>' runat="server" ID="TextBox2" Columns="20"></asp:TextBox><br /><br /><asp:Button ID="UpdateButton" runat="server" Text="Update" CommandName="Update" /><asp:Button ID="CancelButton" runat="server" Text="Cancel" CommandName="Cancel" /> </EditItemTemplate>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ASPNETDBConnectionString1 %>"
SelectCommand="SELECT id, first_name, last_name, email FROM aspnet_test where id = 1"UpdateCommand="UPDATE [aspnet_test] SET first_name = '<%# first_name %>',   last_name = '<%# last_name %>',   email = '<%# email %>'   WHERE id = @original_ID ">
<UpdateParameters><asp:Parameter Name="original_ID" Type="Int32" /></UpdateParameters></asp:SqlDataSource>
Any idea where the @original_ID is supposed to get its value from, or why does the SQL command shows blank fields?Thanks
Eric.

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved