DataSource Controls :: Mapping SqlDataSource Parameters To Formview With Multiple DataKeys?

Sep 1, 2010

a FormView that is linked to SqlDataSource1a Repeater control (inside the formview) that is linked to SqlDataSource2Thus representing a simple "1 to many" or "parent/child" relationship in the database!qlDataSource1 is simple in that it just retrieves a straight set of records from a table and they are displayed back in the FormView (nothing special happening there).SqlDataSource2 has parameters that filter the contents of the repeater based on the record that is shown in the Formview. This would normally be simple enough to set up by setting the parameter to the formview.selectedvalue property.HOWEVER - THE PROBLEM ARISES...The formview has multiple DataKeyNames because the table that the SqlDataSource1 links to has a compound key. So to filter the Repeater correctlySqlDataSource2 needs to map 3 parameters to 3 data key values in the formview.Any ideas how to do this?I've tried setting the SqlDataSource2 parameters to:

<SelectParameters>
<asp:ControlParameter ControlID="FormView1" Name="Parameter1" PropertyName="DataKey(0)" />
<asp:ControlParameter ControlID="FormView1" Name="Parameter2" PropertyName="DataKey(1)" />

[code]...

View 1 Replies


Similar Messages:

DataSource Controls :: SqlDataSource With A Lot Of Parameters?

Sep 4, 2010

I have asked similiar question before where I have two control on the page header says "username" and "gender". User can select both the control or either one and the page will execute searching based on the criteria supplied. So if username supplied

SELECT * FROM [this_table] WHERE username = @username
and if gender supplied
SELECT * FROM [this_table] WHERE gender = @gender
and if both supplied
SELECT * FROM [this_table] WHERE username = @username AND gender = @gender

I know this sounds not very complicated but in my case, I am having like more than 10 controls up there. It is something likeusername, gender, age, date of brith, title, father name, frst name, last name, blur blur blur and it's a lot then I started to lost. if i were to use if else caluse on code-behind and produce query, it would end up writing a lot of if-else and if i use stored procedure (with if-else) then my stored procedure would contains a lot of if-else statement. I am fairly new to this concept and if I'm on the wrong track, please correct me. Is there any better way to save my hair without actually going through each
if-else statement to build the query ?p.s. I'm using GridView and SqlDataSource command to display the result back on .aspx page.

View 2 Replies

DataSource Controls :: Can Use If Else In Sqldatasource If Else Parameters

Oct 4, 2010

I am trying to check whether a username exists in my database before inserting the new row & display a message to the user if it does.

On my SqlDataSource my InsertCommand looks like this:

InsertCommand="IF NOT EXISTS (SELECT * FROM Users WHERE UserName = @UserName) BEGIN INSERT [Users] ([UserName], [FirstName], [LastName], [City], [State], [Country], [CompanyName], [Active], [PasswordHash]) VALUES (@UserName, @FirstName, @LastName, @City,
@State, @Country, @CompanyName, @Active, @PasswordHash) END"

This works as expected: If the username is unique, the row is created.

If the username already exists, the row is not added.

The problem is, if the row already exists, the insert is rejected but the user is not notified.

So my question is, is there a way I can notify the user?

Maybe something like: InsertCommand = "If Not Exists (select....) Begin Insert...Else Notify User Somehow End This is a basic database, I'm not using the built-in membership provider nor will be.

View 1 Replies

DataSource Controls :: All Parameters Null In Update Of SQLDataSource?

Sep 23, 2010

I have a FormView which is bound to an SQLDataSource. When a user clicks on a save button the form, I need to write any changes made to the FormView back to the table.

I have a Stored Procedure on my MSSQL 2005 database that should be executed when the user clicks on the save button.

It appears the Update is firing, but when I trap the DbCommand object in the SQLDataSource's 'Updating' event, all of the parameters that should be passed to the Stored Procedure are coming through as NULLs. Consequently, the Stored Procedure isn't updating anything.

In the click event of the save button I'm explicitly firing the SQLDataSource's Update method:

[Code]....

The parameters in the SQLDataSource <UpdateParameters></UpdateParameters> section appear to be correct.

Can anyone give me an idea on what to investigate to figure out why it appears the Update is only picking up NULLs?

View 1 Replies

DataSource Controls :: Sqldatasource Insert Parameters Wont Set

Mar 9, 2010

if i do this to set the fetch parameters:

dsList.SelectParameters["client_id"].DefaultValue = Session["client_id"].ToString();

where dsList is my datasource, it works.

but wen i do the samething for the *%^&* insert, it doesnt:

dsList.InsertParameters["client_id"].DefaultValue ="1234";

it keeps saying its null, i dont understand why it woudl be doing this?

View 2 Replies

DataSource Controls :: SqlDataSource Variable Number Of Parameters

Mar 7, 2011

I should perform a Query like this Select * from produtcts where model like @MODEL Now if model is selected from combobox, it should be Select * from produtcts where model like '%MODEL1%' while, if selected chooise is null, it should be like each element in my combobox. how should i do this (in SqlDataSource)

View 5 Replies

DataSource Controls :: Programmatically Adding Parameters To SQLdatasource In Codebehind Using C#

Apr 1, 2011

I have a page called Page2.aspx and it is called by another page called Page1.aspx and Page1.aspx passes two parameters namely: Name and Category to Page2.aspx. Does anyone know why the following code from Page2.aspx is not working and it keeps giving an error message as follows: " You have declare the parameter @Username".

string Cat1;
string Name1;

[Code]....

View 2 Replies

DataSource Controls :: Passing Parameters In Sqldatasource Storeproc, Dropdownlist And Textbox

Jun 8, 2010

I got DDL1: 10 miles

20 miles

TextBox1 : 'AAA20'

Button:

When user selects 10 miles from dropdownlist DDL1 and types AAA20 in textbox1 which is of type text, on button click it has to pull all the columns from database and show results in gridview using sqldatasource store procedure. I'm stuck in server side code..how to pull the data..in store procedure I'm passing two parameters val1 and val2. val1 gets data from DDL1 and val2 gets data when user types in textbox1 and it has to validate the text...see the code below mentioned and tell me how to pass the params and get the data in gridview...

[code]....

View 2 Replies

DataSource Controls :: Dynamically Changing SqlDataSource.SelectCommand From FormView.ModeChanged?

Nov 17, 2010

In an asp.net 3.5 web app, I have a page with the following markup/code (this is the brief version, but I believe I got all the relevant info).

[Code]....

The form contains 2 different record types, accessed using the paging controls, depending on the ParentSR field; a parent SR will be something like '1234' while its sub-record will be something like '1234.1'. There are only a few differences in the fields used between the 2 different record types and that is why they are stored in the same table. However, the activity depends on the record type. When browsing from the parent record to the sub-record, the itemtemplate loads fine (notice in the formview's datasource
query, that the sractivity_id field is being pulled along with the subquery value). But when going to edit the record, the page throws an error:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentOutOfRangeException: 'ddlActivity' has a SelectedValue which is invalid because it does not exist in the list of items.

If i click 'back' and retry, it may take 3 attempts, but then the edittemplate will load just fine. I should also point out that this error does not always occur. I've been trying to figure this out for a couple months and it is driving me nuts, mainly due to the fact that I can't reproduce the error in development--it seems to only occurr in production. Anyone with any thoughts on what is going on?

View 1 Replies

DataSource Controls :: SqlDataSource, FormView, And Update With Stored Procedure In Code Behind

Sep 12, 2010

Using a FormView with a SqlDataSource, I'm attempting to Update data

by calling a stored proc in code behind. I was having trouble getting parameters

using Update Parameters in the SqlDataSource, but found a working solution by

coding the parameters.

The problem now is I'm getting an "Updating is not supported by data source 'XYZ' unless UpdateCommand is specified'.

View 3 Replies

DataSource Controls :: Use Sqldatasource From Code Behind With Datacontrols Like Gridview,detailsview And Formview?

Aug 1, 2010

Is Sqldatasource powerful? Is there any disadvantage using it over other controls?

And How to use Sqldatasource from code behind with datacontrols like gridview,detailsview and formview?

Is it possible to completely customize the gridview using sqldatasource from code behind?

View 6 Replies

Forms Data Controls :: Tie DataSource To SqlDataSource On Aspx Page And Pass Select Parameters?

Nov 10, 2010

[code]....

Is ther a way I can tie DataSource to SqlDataSource on aspx page and pass select parameters?

View 6 Replies

DataSource Controls :: Linking Multiple DropDownLists To A Single SQLDataSource?

Jul 16, 2010

I'm attempting to hook up multiple DropDownLists to a single SQLDataSource, but I want the SQLDataSource to return different rows depending on which DropDownList it is populating.

Say I have a table full of names (we'll call it TABLE_NAMES):

[code]....

....and I have two dropdown lists, one with a list of person names and one with a list of dog names.

Is there a way to link up each of these dropdown lists to a single SQLDataSource and use the SelectParameter to differentiate between which records I want returned for each dropdown list?

To make matters worse, these dropdown lists will appear within a GridView control....so there will be multiple instances of each dropdown list depending on how many rows there are in the GridView.

View 1 Replies

DataSource Controls :: SqlDataSource And Parameters Query / Trying To Accomplish Is Building Dynamic Query

Aug 22, 2010

1. I have a GridView on my page and it uses sqldatasource with parameterized query. What I want to do is, on page load (where nothing has been selected so no parameter supplied), I want it to query everything (something like SELECT * FROM [this_table]) but since my SelectCommand is something like

SELECT * FROM [this_table] WHERE [this_column] = @someParameters AND [that_column] = @someParameters.

Can I play around with default value to achieve something like that but how ? Now, when the page loads, it doesn't show anything (No Gridview).

2. On my page, I made something like (username, gender, address, and more) and one single search button. That means, no single control enable auto postback. What I am trying to accomplish is building dynamic query

(if username specifed -> SELECT * FROM [this_table] WHERE [username] LIKE @username).

If both username and gender are specified (SELECT * FROM [this_table] WHERE [username] LIKE @username AND [gender] = @gender) and you know the rest. How can I do this using GridView and SqlDataSource ? To my knowledge, I can only specify one SELECT statement in a sqldatasource.

View 11 Replies

DataSource Controls :: SelectParameterS Multiple Parameters?

Oct 4, 2010

I want to pass to a DataSource(SQL, Linq) more than one SelectParameter or what ever will do the work.I have many ArtistIds i want to pass to my source, so that it will display only those entries with my Parameters.My Problem is, that i dont know in which Format i can pass more than one Parameter, till now i used QueryStrings but that only works for one Parameter, no? I have a DataTable filled with all my IDs and im system-caching it to pass it from a Search-Site to a Detail-Site, maybe theres a better way?

This is my Source:

<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:MvcMusicStoreConnectionString %>"
SelectCommand="SELECT Album.Title, Album.Price, Album.AlbumArtUrl, Artist.Name, Genre.Name AS Expr1 FROM Album INNER JOIN Artist ON [code]...

View 1 Replies

Forms Data Controls :: Use Multiple Datakeys In Nested Gridview?

Jul 22, 2010

my page based on master and Details. there are two gridview one is header and other detail.detail gridview is inner gridview.so when i click on + symbol then details should diplay.i use dataKeys for display Inner gridview record.when i use one datakeys then it is working fine but i need two condtion for show Inner Gridview. how can use multiple datakeys here?my HTML code is below. just modify it for multiple Datakeys

[Code]....

View 8 Replies

DataSource Controls :: SQLDataSource And Tie A SqlDatasource To A Stored Procedure

May 14, 2010

I am trying to tie a sqlDatasource to a Stored Procedure. The stored procedure looks like...

[Code]........

View 2 Replies

MVC :: Parameters Not Mapping To Action

Nov 12, 2010

I have a problem getting a (very simple wep app this is) parameter to map into my action. The controller code action:

[Code]....
My global.asax:

[Code]....

Problem: Calling a url like /Ax/Delete/525782 always returns the 'ParameterNotFound'-view. Its been bugging me for several hours

View 4 Replies

Mapping Route And Parameters In MVC?

Mar 29, 2010

In Area VIPUsers I have controller ProfileController and other controllers.

If I want every method in ProfileController to have parameter (id) and every method in other controllers to have parameter (userid and id) how would I map it?

Would it be

context.MapRoute("ProfileMapping", "VIPUsers/Profile/{action}/{id}",
new {controller="ManageUsers", id=""});

and then map a default one for all the controllers?

context.MapRoute("Default", "VIPUsers/{controller}/{action}/{userId}/{id}",
new {action="Index", userId="", id = ""});

If I go to a page on ProfileController and give it two parameters after {action} (VIPUsers/Profile/SomeAction/4/4/), it'd use the second mapped route. Is that correct?

View 1 Replies

Forms Data Controls :: Values From Multiple (non Primary And Primary) Datakeys?

Mar 6, 2011

I have the following gridview (ID=Gridview1)

I have added pid (primary key), chkblood,chkurine,chkstool,chkmalaria as datakeynames.

what I want to pull off here is .... when I click select I'll be redirected to this wizard

[Code]....

I did that....now I want to hide / skip steps in the wizard depending on the condition of checkboxes (chkblood, chkurine,chkstool,chkmalaria)

but I cant get the value from these non-primary datakeynames...

View 2 Replies

Forms Data Controls :: SqlDataSource Pass Parameters

Mar 15, 2011

I have big filter coming from database by using storedprocedure. This stored procedure contains about 12 parameters. In asp.net page I select these values and after doing that I want to pass these values to SqlDataSourec which is bound to gridview. How can I pass these values to SqlDataSource, manually in codebehind?

View 8 Replies

Forms Data Controls :: How To Add 2 Parameters To One Field Using SqlDataSource

Sep 2, 2010

I am working on a form that I would like to display a dropdownlist or textbox to insert data into the same field.

Currently it is setup where the end user can use one or the other but not both. I am running into a problem getting with the insert parameters for the secondary control. In this case the textbox.

Is it possible to use and Or statment in my Insert Query? I have tried to no avail.

[Code]....

View 3 Replies

Forms Data Controls :: Updating Formview With SqlDatasource?

Dec 13, 2010

I am using a stored procedure for a sqldatasource to update a formview. I believe that I am passing the Obligation_Status value correctly to the stored procedure but the oblgation status field is always updated AS NULL in the database. Does anyone know what I am doing wrong?

[Code]....

[Code]....

View 2 Replies

DataSource Controls :: Mapping Sql Server Date Into And Out Of C# Property?

Mar 6, 2010

Sql Server 2008 introduced a number of new data types. One of those types is Date. I have been trying to find the C# equivalent of the Date data type. Before I start using the Date data type I have a few questions. Am I correct that I still need to use the DateTime Data type in C# when mapping data to and from Sql Server? I am using Linq to Sql. Are there any conversion issues that I need to be aware of when mapping the Sql Server Date into and out of a C# DateTime property?

View 2 Replies

ADO.NET :: Entity Framework - Stored Procedure Mapping, Excecuting SP With Float Parameters Separated By Commas

Sep 27, 2010

Im using Entity framework with POCO entity generator template + SQL Server. I have mapping to stored procedure that takes two floats as input.

After executing function from code with two doubles as parameters: 1.23 and 4.56, SQL Profiler shows:

exec storedProcedureName @arg1 = 1,23, @arg2= 4,56

This is causing an error because it looks like that stored procedure takes 4 arguments, but it should take only two and there should be dots insted of commas in these floats.

[code]....

View 3 Replies







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