Sqldatsource:SelectParameters:FormParameter Not Effective Till Postback?
Nov 14, 2007
I have a simple gridview that loads on page load. It uses an on page sqldatasource declaration in which there's a parameter in which value is already available in cookies. I added an asp:HiddenField and set that value on PageLoad() to the value of the cookies. I then set a FormParameter in the sqldatasource mapped to that hidden field. However that appears to have no effect at all. I'm guessing the sqldatasource will only use the form field after postback.
View 2 Replies
ADVERTISEMENT
Sep 10, 2015
I have two tables. Status and Fourhistory tables.Status table contains a status column with effectivestart and end dates as history. This column is having history at month level.
Fourhistory table maintains 4 columns as part of history with the use of effectivestart and end dates. Here history capturing is at day level.
Desired Result: I want to merge the status column into FourHistory table.Below i have given some possible sample scenarios which i face and the third table contains the expected ouput.how to achieve this in T-SQL query.
create table dbo.#Status(
ID varchar(50),
Status varchar(50),
EffectiveStartDate datetime,
EffectiveEndDate datetime,
Is_Current bit
[code]...
View 4 Replies
View Related
Jul 20, 2007
We've got an employee database that I'm modifying to include two photos of each employee, a small thumbnail image and a full-size image. The HR department maintenance page contains a listbox of employee names, which, when clicked, populates a detailsview control.To get the images to display and be updatable, I've had to structure the following SqlDatasource and DetailsView:
1 <asp:DetailsView ID="dvEmp" runat="server"2 AutoGenerateRows="false"3 DataSourceID="dsEmpView"4 DataKeyNames="empID">5 <Fields>6 <asp:CommandField ShowEditButton="true" ShowCancelButton="true" ShowInsertButton="true" />7 <asp:BoundField HeaderText="Name (Last, First)" DataField="empname" />8 <asp:TemplateField HeaderText="Thumbnail photo">9 <ItemTemplate>10 <asp:Image ID="imgThumbnail" runat="server" ImageUrl='<%# formatThumbURL(DataBinder.Eval(Container.DataItem,"empID")) %>' />11 </ItemTemplate>12 <EditItemTemplate>13 <asp:Image ID="imgThumbHidden" runat="server" ImageUrl='<%# Bind("thumbURL") %>' Visible="false" />14 <asp:FileUpload ID="upldThumbnail" runat="server" />15 </EditItemTemplate>16 </asp:TemplateField>17 <asp:TemplateField HeaderText="Full Photo">18 <ItemTemplate>19 <asp:Image ID="imgPhoto" runat="server" ImageUrl='<%# formatImageURL(DataBinder.Eval(Container.DataItem,"empID")) %>' />20 </ItemTemplate>21 <EditItemTemplate>22 <asp:Image ID="imgPhotoHidden" runat="server" ImageUrl='<%# Bind("photoURL") %>' Visible="false" />23 <asp:FileUpload ID="upldPhoto" runat="server" />24 </EditItemTemplate>25 </asp:TemplateField>26 </Fields>27 </asp:DetailsView>28 29 <asp:SqlDataSource ID="dsEmpView"30 runat="server"31 ConnectionString="<%$ ConnectionStrings:eSignInConnectionString %>"32 OnInserting="dsEmpView_Inserting"33 OnUpdating="dsEmpView_Updating"34 SelectCommand="SELECT empID, empname, photoURL, thumbURL FROM employees where (empID = @empID)"35 InsertCommand="INSERT INTO employees (empname, photoURL, thumbURL) values(@empname, @photoURL, @thumbURL)"36 UpdateCommand="UPDATE employees SET empname=@empname, photoURL=@photoURL, thumbURL=@thumbURL WHERE (empID = @empID)">37 <SelectParameters>38 <asp:ControlParameter ControlID="lbxEmps" Name="empID" PropertyName="SelectedValue" Type="Int16" />39 </SelectParameters>40 </asp:SqlDataSource>41 42 -----43 44 Protected Sub dsEmpView_Updating(ByVal sender As Object, ByVal e As SqlDataSourceCommandEventArgs)45 Dim bAbort As Boolean = False46 Dim bThumb(), bPhoto() As Byte47 If e.Command.Parameters("@ename").Value.trim = "" Then bAbort = True48 Dim imgT As FileUpload = CType(dvEmp.FindControl("upldThumbnail"), FileUpload)49 If imgT.HasFile Then50 Using reader As BinaryReader = New BinaryReader(imgT.PostedFile.InputStream)51 bThumb = reader.ReadBytes(imgT.PostedFile.ContentLength)52 e.Command.Parameters("@thumbURL").Value = bThumb53 End Using54 End If55 Dim imgP As FileUpload = CType(dvEmp.FindControl("upldPhoto"), FileUpload)56 If imgP.HasFile Then57 Using reader As BinaryReader = New BinaryReader(imgP.PostedFile.InputStream)58 bPhoto = reader.ReadBytes(imgP.PostedFile.ContentLength)59 e.Command.Parameters("@photoURL").Value = bPhoto60 End Using61 End If62 e.Cancel = bAbort63 End SubIf the user updates both images at the same time by populating their respective FileUpload boxes, everything works as advertized. But if the user only updates one image (or neither image), things break. If they upload, say, just the full-size photo during an update, then it gives the error "System.Data.SqlClient.SqlException: Operand type clash: nvarchar is incompatible with image".I think this error occurs because the update command is trying to set the parameter "thumbURL" without having any actual data to set. But since I really don't want this image updated with nothing, thereby erasingthe photo already in the database, I'd rather remove this parameter from the update string.So, let's remove the parameter that updates that image by adding the following code just after the "End Using" lines: Else
Dim p As SqlClient.SqlParameter = New SqlClient.SqlParameter("@thumbURL", SqlDbType.Image)
e.Command.Parameters.Remove(p)
(Similar code goes into the code block that handles the photo upload)Running the same update without an image in the thumb fileupload box, I now get this error: "System.ArgumentException: Attempted to remove an SqlParameter that is not contained by this SqlParameterCollection."Huh? It's not there? Okay, so lets work it from the other end: let's remove all references to the thumbURL and photoURL from the dsEmpView datasource. We'll make its UpdateCommand = "UPDATE employees SET empname=@empname WHERE (empID = @empID)", and put code in the dsEmpView_Updating sub that adds the correct parameter to the update command, but only if the fileupload box has something in it. Therefore: If imgT.HasFile Then
Using reader As BinaryReader = New BinaryReader(imgT.PostedFile.InputStream)
bThumb = reader.ReadBytes(imgT.PostedFile.ContentLength)
e.Command.Parameters.Add(New SqlClient.SqlParameter("@thumbURL", SqlDbType.Image, imgT.PostedFile.ContentLength))
e.Command.Parameters("@thumbURL").Value = bThumb
End Using
End If
(Similar code goes into the code block that handles the photo upload)But reversing the angle of attack only reverses the error. Uploading only the photo and not the thumb image results in: "System.Data.SqlClient.SqlException: The variable name '@photoURL' has already been declared. Variable names must be unique within a query batch or stored procedure."So now it's telling me the parameter IS there, even though I just removed it.ARRRGH!What am I doing wrong, and more importantly, how can I fix it?Thanks in advance.
View 5 Replies
View Related
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
Jan 15, 2008
I can think of ways to resolve this issue, but I am wondering if there is a standard practice or some setting that is used to ensure that text containing a single quote, such as "Bob's house", is passed correctly to the database when using a SqlDataSource with all of the default behavior.
For example, I have a FormView setup with some text fields and a SqlDataSource that is used to do the insert. There is no code in the form currently. It works fine unless I put in text with a single quote, which of course messes up the insert or update. What is the best way to deal with this?
Thank you
View 10 Replies
View Related
Apr 30, 2014
I have a table with 5000 rows history about working and retired time.
It is the several rows from table(User, StartDate, EndDate):
User1 2011-05-09 00:00 2014-01-17 00:00
User2 2012-07-01 00:00 2012-08-20 00:00
User2 2013-08-26 00:00 2013-09-02 00:00
User2 2013-10-07 00:00 NULL
User3 2013-09-01 00:00 2014-04-07 00:00
User3 2014-04-08 00:00 NULL
How many users have worked and have retired by years and months,
Example:
2011-01 working 2000
2011-02 retired -50
2011-02 working 1950
2011-02 retired -27
and etc,,
Does it need to join to a time dimension table?
View 7 Replies
View Related
Oct 29, 2014
Attached is a file that generates a sample dataset from which I want to forecast a value for column 'Parcel Count 2014' from tomorrow (30/10/2014) till the end of December (31/12/2014). The forecast should be based on values from column 'Parcel Count 2013' for the same Month.
View 9 Replies
View Related
Feb 13, 2008
I provide default values for parameters, but we need to wait for the user to click "View Report" before the report is run. It is an expensive report to run, and the user needs the defaults, but also needs to be able to change them before execution. I cannot find a setting for this. Is there a way to do this that does not involve adding dummy parameters? (that's too tacky a solution!)
View 4 Replies
View Related
Aug 20, 2015
I have sales from 2010 to today in my cube. my question is i want to see sales amount from 2010 to 2014 if i select 2014. or if I select 201405 ( may 2014), i want to see sales from 20100101 to 20140531. same with date. basically i want to to al the sales til the date/month /year selected. how can i achieve this?
View 2 Replies
View Related
Sep 2, 2015
There is a huge empty space between my tablix which is inside a rectangle to the footer.
I need to be able to fit another row but the other rows go on to the second page. How can I fix this?
View 8 Replies
View Related
May 3, 2008
I want that a textbox do a postback after I change the text : I change autompostback to true , It's do a postback after
I press on the enter button , how can I do automatic postback after the text change without press on the enter button?
View 1 Replies
View Related
Mar 20, 2008
Hi.
We have a problem. The sql insert don't work together with postback on the insert button. The following solution has been sugested:Partial Class Login
Inherits System.Web.UI.Page
Protected WithEvents loginButton As Button
Protected Sub loginButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles loginButton.Click
Response.Redirect("Tunnel1.aspx")
End Sub
End Class
But it doesn't work (the data is saved in the databse but the page isn't redirected to "Tunnel1.aspx"), why?
Here is the code for the page:<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Login.aspx.vb" Inherits="Login" title="Untitled Page" %>
<asp:Content ID="Main" ContentPlaceHolderID="Main" Runat="Server">
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:DatabaseConnectionString %>"
InsertCommand="INSERT INTO konsult(användarnamn, lösenord) VALUES (@användarnamn, @lösenord)">
</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 width="100%" align="right">
</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">
<table width="100%">
<tr>
<td width="150">Användarnamn:*</td>
<td width="250"><asp:TextBox Width="150" ID="användarnamnTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("användarnamn") %>' /></td>
</tr>
<tr>
<td width="150">Lösenord:*</td>
<td width="250"><asp:TextBox Width="150" textMode="Password" ID="lösenordTextBox" runat="server" Font-Size="X-Small" Text='<%# Bind("lösenord") %>' /></td>
</tr>
<tr>
<td width="150">Upprepa lösenord:*</td>
<td width="250"><asp:TextBox Width="150" textMode="Password" ID="upprepalösenTextBox" runat="server" Font-Size="X-Small" Text="" /></td>
</tr>
</table>
</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">
<asp:Button ID="loginButton" CommandName="Insert" CausesValidation="True" runat="server" Text="Spara" />
</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">
<asp:CheckBox ID="CheckBox1" runat="server" Text="Jag godkänner att mina personuppgifter registreras enligt PUL." />
</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>
View 2 Replies
View Related
Jan 7, 2006
If I alter the SqlDataSource select command in code and then bind to a gridview, I run into problems. When I do a sort, next page (basically any postback), the datasource goes back to the original state. It is like the SqlDataSource is not maintained in the state. I end up having to re-alter the SqlDataSource select command on every page_load. Is this by design or is this a bug?
Is the SqlDataSource any "smarter" than doing it the old fashion way by populating a Dataset on (!IsPostBack) ? For example, if I have a bunch of data in a paged gridview, is the SqlDataSource smart enough not to bother filling the entire dataset if I don't need it for that page's display? I know the SqlDataSource provides for update/insert/delete, but I am not doing that in this application, it is just a query/report page.
Thanks in advance
View 4 Replies
View Related
Mar 21, 2007
Hi,
I'm working on a report having 2 date parameters(which uses calendar control) and a dropdownlist. But on selecting each of these parameters, the page refreshes. For eg On selecting a date from the calendar control results in a postback. The same is the case with the dropdownlist. Could you please help to resolve this issue? We need the postback to happen only on clicking the 'View Report' button.
Also, is there any way to customize the 'View Report' button. It always appears in the right hand side. Can we set the position of this button so that it appears just below the paging button?
Thanks in advance,
Sonu.
View 1 Replies
View Related
Dec 7, 2006
Hey,
I hope someone can quickly tell me what I am obviously missing for this weird problem.
To give a general picture, I have an ASP.net webpage that allows users to select values from several dropdown menus and click an add button which formats and concatenates the items together into a listbox. After the listbox has been populated the users have the option to save the items via a save button.
The save button parses each item in the listbox to basically de-code the concantenated values and subsequently inserts them into a table residing on a backend MSSQL 2005 database.
PROBLEM:
In the process of testing the application, I noted this strange behavior. If I use the webpage to insert the values, go to the table where the values are stored and delete the rows; Upon a refresh of the web page the same actions seem to be getting replayed and the items are again inserted into the table.
Naturally, what I'd really like would be for the page to refresh and show that the items aren't any longer there and not the other way around.
If the code that performed the insert was residing in a component that was set for postback I'd expect this type of behavior but its in the Save buttons on_click event. I have tried practically everything in effort of targeting the problem but not having much luck with it.
Is this behavior practical and expected in ASP.net or has anyone ever heard of anything similar? I have never encountered this type of problem before and was hoping someone could provide some clues for resolving it. If more information is required I'd be happy to supply it. Hopefully, there's a simple explanation that I am simply unaware since I haven't experienced anything like this before.
Anybody got any ideas???
Thanks.
View 6 Replies
View Related
Jul 26, 2006
I think it has been discussed previously that having default parameter values based on expressions, e.g. a default parameter value of =Split("Bug",",") in multiple parameters will cause a postbacl whenever a user selects different values from the list.
Is this by design? Its a bit of an annoying thing. The refreshpostback doesnt happen if you have basic defaults like ="All" but only when an expression of some sort is used in more than 1 parameter. Does RS think they are linked or something, why does it need to psotback
efresh?
View 23 Replies
View Related
Oct 18, 2007
Hi,
Please give me some idea to persist or set title of modal dialog during postback.
The title of modal dialog is going lost whenever postback happen on modal dialog.
document.title is not working after postback.
Thanks,
Sandeep, India
View 1 Replies
View Related
Jan 21, 2008
Hi Everyone-
i have a report that include a parameter of type date and it is visible to the user in order to choose the date and submit view report button to rendering the report.
i don€™t know if it is a bug in SSRS or not
but the problem is that if the user try to click on the date button of the parameter and choose a date
And then try to click again on the date button and choose a date another date .....after repeat the previous step more than one time the page is post back and reset the report and this not desirable by our client
Note:
Again the date button I am mention is the date button that auto generated by the SSRS as there is a parameter of type date
This Case happen only if the report run through a browser
Thanx
Maylo
View 1 Replies
View Related
Apr 28, 2008
I have a report which includes two fields of type date pFromDate and pEndDate.
My pFromDate Available values is 'No-queried', and Default values is 'Null'.
My pEndDate values is 'No-queried', and Default values is the
expression '=DateValue(Today)'.
After I upload my report to the report server and run it pEndDate is disabled until I choose value to pFromDate and a postBack occurs.
I want pEndDate display the evaluated expression automatically when I run the report.
How can I do it? Thanks in advance.
View 1 Replies
View Related
Feb 10, 2008
Hi there!Basicly I only want to retrieve the value of the field "FirstTime" from a record as shown below:1
2 Dim ProdUserID As String = "samurai"
3
4 Dim LoginSource As New SqlDataSource()
5
6 LoginSource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
7
8 LoginSource.SelectCommandType = SqlDataSourceCommandType.Text
9 LoginSource.SelectCommand = "SELECT FROM aspnet_Users (FirstTime) VALUES (@FirstTime) WHERE UserName=@ProdUserID"
10
11 Dim SeExiste As Boolean = LoginSource.SelectParameters.GetValues("@FirstTime")
12
This is the error reported:Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: BC30455: Argument not specified for parameter 'control' of 'Public Function GetValues(context As System.Web.HttpContext, control As System.Web.UI.Control) As System.Collections.Specialized.IOrderedDictionary'. Please can you answer in the same logical schema? I'm a newbie so if you may, describe the process step by step. It would be easier for me to understand.Thanks in advance.
View 1 Replies
View Related
Mar 10, 2008
What am I forgetting to do? I am setting the SELECT parameter 'techcode' in the code behind trying to paqss it as the ZWOP in my SQL Select statement but it is not getting to the SQl SelectParameters statement. Do I need to place a TextBox control on the ASPX page to hold it?
ERROR: Exception Details: System.InvalidOperationException: Could not find control 'techcode' in ControlParameter 'ZWOP'.
CODE BEHINDint techcode;protected void Page_Load(object sender, EventArgs e){ techcode = 11; }
ASPX CODE. . . SelectCommand="SELECT [ZL_ID], [complete], [error], [Zip], [ZipCity], [ZipState], [ZWOP] FROM ZipData WHERE ([complete] = 0 OR [complete] IS NULL ) AND [ZWOP] = @techcode ORDER BY Zip" <SelectParameters> <asp:ControlParameter ControlID="techcode" Name="ZWOP" PropertyName="SelectedValue" Type="Int16" /> </SelectParameters>
View 8 Replies
View Related
Apr 3, 2008
What im looking to do is put a checkbox on my page and if the box is checked have it add a where clause to the sql statement.
The most i have seen with selectparameters is for it to basically take the value of the given control (or whatever) and dump it in to a query.
In this case what i would like to do is if the box is not checked it has my basic query run Select * from Table
and if the box is checked i would like it to run Select * from table where status='completed'
basically a check box that shows only completed items.
wasnt sure if i could do this with just the sqldatasource control and some selectparameters or if i had to write some code.
Thanks
Justin
View 5 Replies
View Related
Sep 5, 2007
Hi,
I am working on a report (in 2005 version) having 6 date parameters ( which uses calendar control). When on selecting the date parameter(except the last data paramenter), the page refreshes. For eg On selecting a data from the calendar control results in a postback. but if I select the last data paramenter, the page is not refreshed.
I did another test on a report that only has 2 data paramters (use the calendar control), it is the same. you select the second the data parameter, no postback happened, but if you select the first data parameter, the postback happened.
Dose anybody know what is the issues? We need the postback to happen only on clicking the 'View Report' button.
Thanks in advance,
TH
View 3 Replies
View Related
Oct 24, 2006
Hi , I am trying to write a report generator by simply using a form and then a gridview that query's the database based on what the user selects on the form. Anyways, I update the SQL parameters similar to below code. I just want to know how i can tell the parameter to get ALL values from the parameter instead of a specific value. For example if the user wanted to see ALL the records for CustomerName what would i set the parameter default value to? I tried the asterisk but that did not work. Please guide me....Thanks! MattSqlDataSource1.SelectParameters["CustomerName"].DefaultValue = "some value";<asp:SqlDataSource ... > <SelectParameters> <asp:Parameter Name="CustomerName" /> </SelectParameters></asp:SqlDataSource>
View 1 Replies
View Related
Feb 16, 2007
Hi,
I am using Visual Web Developer 2005 Express Edition.
I am trying to SELECT three information fields from a table when the Page_Load take place (so I select the info on the fly). The refering page, sends the spesific record id as "Articleid", that looks typically like this: "http://localhost:1424/BelaBela/accom_Contents.aspx?Articleid=2". I need to extract the "Article=2" so that I can access record 2 (in this example).
How do I define the SelectParameters or QueryStingField on the fly so that I can define the WHERE part of my query (see code below). If I remove the WHERE portion, then it works, but it seem to return the very last record in the database, and if I include it, then I get an error "Must declare the scalar variable @resortid". How do I programatically set it up so that @resortid contains the value that is associated with "Articleid"?
My code is below.
Thank you for your advise!
RegardsJan/*******************************************************************************
* RETRIEVE INFORMATION FROM DATABASE
*******************************************************************************/
// specify the data source
string connContStr = ConfigurationManager.ConnectionStrings["tourism_connect1"].ConnectionString;
SqlConnection myConn = new SqlConnection(connContStr);
// define the command query
String query = "SELECT resortid, TourismGrading, resortHits FROM Resorts WHERE ([resortid] = @resortid)";
SqlCommand myCommand = new SqlCommand(query, myConn);
// open the connection and instantiate a datareader
myConn.Open();
SqlDataReader myReader = myCommand.ExecuteReader();
// loop thru the reader
while (myReader.Read())
{
Label5.Text = myReader.GetInt32(0).ToString();
Label6.Text = myReader.GetInt32(1).ToString();
Label7.Text = myReader.GetInt32(2).ToString();
}
// close the reader and the connection
myReader.Close();
myConn.Close();
View 3 Replies
View Related
Apr 4, 2007
Hello,
I am sure there is a way to do this programmatically, but it is just not sinking in yet on how to go about this. I have a page where I use a dropdownlist that goes into a gridview and then the selected item of the gridview into the detailsview (typical explain seen online). So, when selecting from the dropdownlist, the gridview uses a controlparameter for the selectparameter to display the appropriate data in the gridview (and so on for the detailslist).
My question is - I wanted to use this same page when coming in from a different page that would utilize querystring. So, the parameter in the querystring would be for what to filter on in the gridview, so the dropdownlist (and that associated controlparameter) should be ignored.
Any suggestions on how to go about this? I assume there is some check of some sort I should in the code (like if querystring is present, use this querystringparameter, else use the controlparameter), but I am not sure exactly what I should check for and how to set up these parameters programmatically.
Thanks,
Jennifer
View 5 Replies
View Related
Apr 27, 2008
Hi,
I am using a grid view with parameter defined in dropdown list. the asp code is:
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Pubs %>"
SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors] WHERE ([state] = @state)"
DeleteCommand="DELETE FROM [authors] WHERE [au_id] = @au_id">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="state" PropertyName="SelectedValue"
Type="String" /></SelectParameters>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Pubs %>"
SelectCommand="SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors] WHERE ([state] = @state)"
DeleteCommand="DELETE FROM [authors] WHERE [au_id] = @au_id">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList1" Name="state" PropertyName="SelectedValue"
Type="String" />
</SelectParameters>
</asp:SqlDataSource>
</asp:SqlDataSource>
I would like to to set the parameter assignment in my VB code in Page_Load methodWhen i am using:
SqlDataSource1.SelectParameters("state").DefaultValue = DropDownList1.Text
SqlDataSource1.SelectCommand = "SELECT [au_id], [au_lname], [au_fname], [state] FROM [authors] WHERE ([state] = @state)"I get error message saying: Object reference not set to an instance of an object.
Any ideas how I can set the select parameters (in my VB code) to use the dropdown list I have in my page?
Thanks,
Uzi
View 8 Replies
View Related
Dec 30, 2005
Hi All,
I'm trying to set the SelectParameters of SqlDataSource from the code behind.
This is my query: SELECT * FROM [UploadSessions] WHERE ([OwnerID] = @OwnerID)And I need to set the value of the @OwnerID at the code behind since it is stored in an object.
How can I do it??
Thanks in advance
Bar
View 7 Replies
View Related
Nov 25, 2005
Hi, I have created a search page which needs to perform different
search function in same page. I have setuped a sqldatasource then
manual
setup the connection string and command inside the codefile. So the
select command can be various depends on the event. The problem is
all of those setting will be reset after I click on the pageindex in
the girdview control to go to next pages. Since this gridview is linked
with this sqldatasource control, I need to restore the connection
string/command when user choose decide to view next page of data inisde
the
gridview.
I think I must have done something wrong in here becuase it will end up
retrieving the total amount of data when everytime user choose to
view next
or perivous page.
Can someone give me a hand on this ? Thanks
View 1 Replies
View Related
Oct 24, 2006
Hi,I have a GridView which is bound to a SqlDataSource that connects to Oracle. Here's the code: <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:OracleConnectionString %>"
ProviderName="<%$ ConnectionStrings:OracleConnectionString.ProviderName %>" SelectCommand="SELECT QUIZ.TITLE FROM QUIZ WHERE (QUIZ.USERNAME = @UserName)"> <SelectParameters> <asp:SessionParameter Name="UserName" SessionField="currentUser" Type="String" /> </SelectParameters> </asp:SqlDataSource> As you can see I'm trying to pass the value of the "currentUser" session variable to the query. I get an error message "ORA-xxx Illegal name/variable". Where am I going wrong? I tested the connection by placing a specific value instead of the "@UserName" and it worked.
View 1 Replies
View Related
Nov 24, 2006
Column1 in table 1 has a range from 1 to 5 (int)
A CheckboxList displays these 5 items. When checked (for example 1 and 4) I want a gridview with sqldatasource=sqlProducts to display the records where column1 values 1 or 4.
When I use the code below I only get the records where column1 values 1....
<asp:SQLDataSource id="sqlProducts" Runat="Server" SelectCommand="Select * From Table1 where Column1 IN (@CBLchecked_items)" ConnectionString="<%$ ConnectionStrings:pubs %>"> <SelectParameters> <asp:ControlParameter Name="CBLchecked_items" ControlID="CBL" propertyname="SelectedValue" type="String" /> </SelectParameters></asp:SQLDataSource>
View 2 Replies
View Related
Feb 28, 2007
ALTER PROCEDURE dbo.Default_Edit1
(
@ID int,
@Family Nvarchar (100) OutPut
)
AS
/* SET NOCOUNT ON */
SELECT @Family=Family FROM Table1 where (ID=@ID)
RETURN
SqlDataSource1.SelectParameters.Add("ID", Me.GridView1.DataKeys(CInt(e.CommandArgument)).Item(0))
SqlDataSource1.DeleteCommandType = SqlDataSourceCommandType.StoredProcedure
SqlDataSource1.SelectCommand = "dbo.Default_Edit1"
SqlDataSource1.SelectParameters("Family").Direction = Data.ParameterDirection.Output
Label3.Text = SqlDataSource1.SelectParameters("Family").Direction.ToString()
it's have error
I went to return 1 fild
??
View 2 Replies
View Related
Mar 14, 2008
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CollegeDatabaseConnectionString %>" SelectCommand="SELECT employee_datails.* FROM employee_datails WHERE memberid !=@id OR memberid OR memberid==uid"> <SelectParameters> <asp:SessionParameter Name="id" SessionField="userid" /> <asp:QueryStringParameter Name="uid" QueryStringField="memberid" /> </SelectParameters> </asp:SqlDataSource> I tried like this but it is not working. It takes at a time one sessionparameter or querystringparameter. I want if profile.aspx--> then i want session parameter in select queryIf profile.aspx?id=12432---> then i want querystringparameter in select query.
View 2 Replies
View Related