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?
Thanks
Brad
View 3 Replies
ADVERTISEMENT
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
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
Apr 17, 2008
Does anyone know if this is possible right out of the box in SSRS 2005 against an OLAP data source?
I have several parameters. My second parameter is to be filtered based on the first parameter (kinda like cascading), but how do I do this against an OLAP data source? Lets say I have param1 and param2 in a dataset. I want Param2 to show the locations only based on what I select in Param1.
Same but a little different: I have Parameter1 and then my second parameter (Param2) is a boolean (True/False). I want to show Parameter 3/Paramater 4 based on selection of Param2 (So, if true, show Param3, if false, show Param 4) and remember we are doing this in a sequence.
Can you do this thru SSRS? Any help would be great.
Thanks for your time in advance.
Kent
View 2 Replies
View Related
May 22, 2008
Can someone tell me why the syntax checker is choking on the following code? It doesn't like the SQLDataSource1 reference. Protected Sub cmdSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdSubmit.Click
SqlDataSource1.SelectCommand = "SELECT * FROM users WHERE username='" + Trim(txtUsername.Text) + "' AND password='" + Trim(txtPassword.Text) + "'"
End Sub
Thanks
View 6 Replies
View Related
Nov 6, 2007
Hi all,
Please advise which kind of connection should be establish from excel 95 to MS SQL Server.
From my thought, I understand that the connection depends on Windows version rather than excel version.
Thus, I just think that there will not be any issue connecting to SQL Server from Excel 5.0a.
Kindly advise if there is any addtional point to concern/consider further.
What could be issue connecting to SQL Server 2005 from Excel 5.0a.
Thank you very much
View 1 Replies
View Related
Jul 17, 2007
Hi! I am trying to do something that I would think should be rather simple.I have a SQLDataSource that has a simple select statement.I have a String Variable st_tempI know my SQLDataSource returns only one value, and it's a string.HOW DO I DO somehitng like st_temp=SQLDataSource.Select;I am getting nothing but errorrs Thanks in advance Dan
View 4 Replies
View Related
Apr 5, 2007
Hi !!!
I have a problem, I don't know how to do...
I have 2 dataset from 2 differents XML dataSource...
I want the result of one dataSet to be a parameter for the second !
I try to add a parameter in param tab, with expression, I choose DataSet and
=Sum(Fields!ID.Value, "DataSetID")
but when I execute the query, the prompt for the param appear, but the value of id was <NULL>...
Someone have ideas to resolve this problem ?
thank you for your help !
View 1 Replies
View Related
Jan 22, 2007
Everything I have read says that this is possible in Oracle 9 and greater versions, but I can't get it to work...
Here is my query:
select * from employee where employee_id in ('111','222')
This works fine in the data tab until I replace the values with a parameter. I get the pop-up to enter the parameter values but no matter how I enter them, I don't get any rows returned. I've tried entering them as '111','222' and as 111,222 and changing the parameter type from a string to an int, but nothing seems to work.
I am running this on SQL Server RS 2005 and my Oracle driver (Oracle in OraHome92) is version 9.02.
View 6 Replies
View Related
Feb 23, 2007
hi,
how to pass Datasource Name as input parameter from command propmt to rdl file in sql server 2005?
Thanks,
shanthi
View 3 Replies
View Related
Feb 26, 2007
Hi all,
How must I change the mdx that is generated for the available values for a user parameter in order to get the content sorted?
Regards,
Henk
BTW the exact mdx query is given below (and the label field of the parameter is set to 'ParameterCaption'), but I would already appreciate an example of a simple mdx.
MEMBER [Measures].[ParameterCaption] AS '[Organisatie].[Level 5 naam].CURRENTMEMBER.MEMBER_CAPTION'
MEMBER [Measures].[Nummer en Naam] AS '[Organisatie].[Kosten Nummer].CURRENTMEMBER.MEMBER_CAPTION +": "+ [Organisatie].[Level 5 naam].CURRENTMEMBER.MEMBER_CAPTION'
--MEMBER [Measures].[ParameterValue] AS '[Organisatie].[Level 5 naam].CURRENTMEMBER.UNIQUENAME'
MEMBER [Measures].[ParameterLevel] AS '[Organisatie].[Level 5 naam].CURRENTMEMBER.LEVEL.ORDINAL'
SELECT {[Measures].[ParameterCaption],
[Measures].[Nummer en Naam]
, [Measures].[ParameterValue], [Measures].[ParameterLevel]} ON COLUMNS
, filter ([Organisatie].[Level 5 naam].MEMBERS,[Measures]) ON 1 ,
[Organisatie].[Kosten Nummer] on 2
FROM ( SELECT ( STRTOSET(@OrganisatieLevelnaam, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(@KalenderFactuurPeriode, CONSTRAINED) ) ON COLUMNS FROM ( SELECT ( STRTOSET(@KalenderFactuurJaarNummerLang, CONSTRAINED) ) ON COLUMNS FROM [FMR DWH Afgenomen Dienst])))
View 6 Replies
View Related
Nov 27, 2007
I searched this forum however I could not find an answer to my question. I'm sure it has been asked before but...
In my parameter if the user does not select anything, null, then it returns all the records.
Second question if he selects "All" then it returns all records.
If this is 1st grade stuff please forgive me. I'm pretty new, learning as the needs arise.
Thanks
CardGunner
View 12 Replies
View Related
Feb 20, 2008
I have a question regarding Execute SQL Task as I combined one statement like select count(*) from destination table, and insert into error table (source count, error count, destination count) values (?,?,?).
If I use two Execute SQL Task, it should work. I was wondering that is it possible to combine select and insert into one Execute SQL Task direct input. How to approch this?
View 6 Replies
View Related
Apr 6, 2006
Hello,Is it possible to set a comparison operator using a parameter value?The code below shows what I'm after;declare @co char(1)declare @date datetimeset @co = '<'set @date = '02/02/2002'select * from recipe where date @co @dateI would use an if statement perform two seperate statements depending on the value of co, but this is only one of 13 statements where i need to have different combinations of comparision operators.thanks
View 2 Replies
View Related
Apr 10, 2007
Hello all.
I am on the verge of being able to do exactly what I want, but just can't seem to find the right combination of things to do it. I'm sure all of you wonderful folks will be able to point it out to me immediately, but I've been looking at it too long or something....
I have a record of individual sales with the state, and quarter of the sale.
sale_id state quarter
001 NY 2005Q1
003 WI 2006Q2
etc.
I create a report with a matrix to show count(sale_id) with Quarter as the column group and State as the row group. This works fine.
Now what I want to do is to get percentages based on quarterly sales. In other words, what percent of sales for 2005Q1 in NY vs. all sales in 2005Q1. So I create a second dataset (called total) with an SQL query like so:
SELECT count(sale_id)
FROM data_table
WHERE quarter = @QueryQuarter
Now, back in the matrix I want to use the column that we're in (2005Q1, 2005Q2, etc.) as the value that is passed to this query.
This is a simple concept, but I can't seem to figure out the correct call to pass the column group to the query as the parameter.
Thank you for any pointers you might be able to give. As I said, I'm right on the verge and just can't quite get it.
cmk
View 3 Replies
View Related
Jan 27, 2006
I want to set defaults for my multi-valued report parameter MONTH so that when the report starts, it automatically selects all the months prior to the current month (effectively creates a YTD report). However, using RS2005, I can't seem to figure out how to do this. I can create an IIF expression in 12 different value entries in the report parameters that returns the month based on the system date, but the first time I pass blanks, null or anything except a valid parameter, it clears the entire parameter list when the report displays.
Does anyone have any suggestions for auto-populating multiple values in a parameter at runtime where one or more of the parameter values may be empty? Checking "Allow Null" or "Allow Blank" doesn't fix this problem.
I tried to pass all the values in a single value entry on the report parameters page, but can't find the syntax that will allow this. I'm not sure if it will let you do that anyway...
Trent
View 3 Replies
View Related
Jan 21, 2008
we're trying to get a better understanding of how RS behaves when parameters are being set. We see quirky behavior that is a little difficult to describe. Right now we assume that if the revolving green circle (with the phrase "Report is being generated" beneath it) doesnt appear, the report really wasnt rendered properly, even if the report region changes.
One peculiarity that seems pretty consistent is on reports we've prototyped with "from" and "to" date parameters. It seems that when we set one date (doesnt matter which is 1st) things progress normally, ie no "report clearing event" occurs as a result of setting cursor focus in the calendar control and changing its value. The report region doesnt change from what showed previously. But trying to set focus on 2nd (doesnt matter if its "from" date or "to" date, just that its the 2nd date being set) always seems to trigger some kind of event that 1) doesnt allow focus to be on that text box, 2) blanks out the report region including headings. Only after this "event" occurs, can we set focus on the 2nd date, change the value and click the "view report" button for rerendering.
We see similar types of behavior with other types of parameters that include multi value dropdowns and booleans. The toughest part of this is trying to explain it to our users. On some parameters, the event always occurs every time they are changed. On other parameters, it appears that the event only occurs if another parameter was changed beforehand.
I believe we've even seen headings with no data rendered, thinking temporarily that no rows were returned, just to find out that by clicking the "view report" button there really was data to be reported based on current filters. Unfortunately I cant reproduce this scenario when I want to.
View 3 Replies
View Related
Jan 26, 2007
Hi all,
Does sombody have experience on dynamically set or change the default value of a report parameter?
Assuming: report parameters p1, p2, p3, p4 have been set up(and have their default value 'all') with the creation of the report1; report browseing is through reportviewer that embedded in the web application; datasource is datacube
What I want to do: based on the login user of the my web application, set default value of p1 as the user's username.
What I did is:
Microsoft.Reporting.WebForms.ReportParameter reportParam = new Microsoft.Reporting.WebForms.ReportParameter("P1","Mary");
ReportViewer1.ServerReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter []{ reportParam });
what I got when reveiw the report:
P1 has no default value, and p2, p3, p4 greyed and could not choose value from them.
Any idea and suggestion will be pre-appreciated!
Jone
View 1 Replies
View Related
Jun 17, 2008
Hi everybody,
Is there a way to set SelectParameter for SQLDataSource in ASPX file using System.Configuration.ConfigurationManager.AppSettings["SiteID"]) ?
Thanks a lot in advance.
View 8 Replies
View Related
Aug 21, 2007
How can I set the multivalue parameter list's default option to <Select All> ?
View 2 Replies
View Related
Feb 19, 2007
Hi,
I'm pretty new to ASP.NET and VB, but I'm working on a project which is essentially a staff directory. Using VS 2005, I've setup a basic grid view which connects to an object which connects via a data layer to a SQL database with Name, Surname, Email, Extension No and Department fields.
I have it working so that if a user enters a name and surname for example, it will return all records with either the name matching or surname matching input parameters. What I want to do is to set up a SQL query which is:
SELECT * FROM records WHERE (Name LIKE @Name) AND (Surname LIKE @Surname) AND (Email LIKE @Email) AND (Dept LIKE @Dept)
so that if the user only enters the first name and surname for example as above, it ONLY returns the record which matches the first name and surname and not all records with either/or. One way I've thought of to do this is to convert the empty fields to "Nothing" so that it fullfils the search parameter for the empty fields. If someone can explain how to do this, or can suggest a better way, I'd be grateful.
Cheers,
Tom
View 3 Replies
View Related
Jun 3, 2015
I have a report with a subscription enabled and the default values that are selected for the report frequently change. I have our report server locked down so that the users can't change the defaults, but I now want to empower them to maintain this on their own. Here is my dilemma. When you have the available parameters set up to pull from a query, the defaults on the report server have to be keyed in manually, which is not an option. The only way to get a check box there, is to explicitly specify the available values.I need my available values to be database driven and I need to be able to select my defaults on the report server using check boxes.
View 5 Replies
View Related
Oct 24, 2007
Hello,
I have a report which displays a customers invoice, in both the companys local currency, and the customers local currency.
The report language is "English (United Kingdom)"
The fields showing customers currency language setting is set to something else, i.e. "France (French)" to display the Euro currency.
The application handles 34 currencies, the query returns the language string, ("France (French)"), to allow the report to bind its language setting to the querys output.
However, it doesn't work, a normal textbox will display the correct country name string, but Reporting Services cannot bind the language setting to a query result. So I also tried setting it as a report parameter, but no joy either (all currencys revert to USD).
I'm using =First(Fields!curFormat.Value, "myDataSet") to bind the 'language' setting, the result of this expression returns "France (French)", which is a valid option for this language setting, as it's in the drop down list.
Rather than create 34 seperate reports for each currency, are there any suggestions on how to bind a fields language setting to a query result?
View 3 Replies
View Related
Aug 3, 2015
I have a multi value parameter called "Location" and this depends on another multi valued parameter value. The default value for the parameter "Location" comes from the another another multi valued parameter. Now say when the default value is set for the parameter Location like the below:
The Location parameter data set has values from the Query and default values has been set as shown below:
=Iif(array.IndexOf(Parameters!Program.Value,"A")>-1,nothing,"N/A")
I get an error on preview saying that . The Default Expression for the report parameter "Location" contains error:
Unable to cast object of type 'System.String' to type 'System.Array'.
View 2 Replies
View Related
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
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
View Related
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
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
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
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
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() + "<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
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
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