ADO.NET :: Conditional TableAdapter Query - If No ZoneID Is Selected, The Page Passes A Value Of 0?

Oct 19, 2010

Sure could use some guidance and clarification here. This is an ASP.NET 3.5 app built with VS2008.The data is provided through a strongly typed dataset and TableAdapters containing Ad Hoc queries. A requirement on the project was recently modified. Previously, this query was used to select records based on a specified ZoneID:

[Code]....

The requirement now is that if no ZoneID is selected, the page passes a value of 0, it ignores the WHERE statement and selects all records. Otherwise, it passes the integer value to ZoneID and selects all records associated with that ZoneID.

I have tried several variations including CASE statements in the WHERE clause and surrounding the entire query. I also tried [Code]....

By including a SET statement in SQL Server Management Studio, this works. However, Ad Hoc queries in TableAdapters do not support DECLARE statements.

This also did not work: [Code]....

And neither did this: [Code]....

View 2 Replies


Similar Messages:

DataSource Controls :: TableAdapter Using Wrong Query?

Jan 19, 2010

I have a quite baffling problem. I've created a Table adapter with 3 queries. 1. GetMemberData() - Return ALL rows. 2. SearchMembersLastName(@q) - Return specified columns from rows that have a column starting with a specified letter. 3. GetMemberDataById(@id)
- Return all rows matching a specified ID.

The Problem is that SearchMembersLastName(@q) is returning ALL coloumns instead of just the ones I want. Here's the query that's in the Table Adapter:

[Code]....

The problem is that it is acting like:
[Code]....

Here's the code that's calling it:
[Code]....

I just can't figure out why this is happening, any help will be greatly appreciated.

View 4 Replies

Web Forms :: Using TableAdapter To Query A Table In Code Behind?

Nov 24, 2010

I have a webpage that displays the results of a query on a table. The resulting list is sorted by town:

New York

Hyatt Regency Waldorf Astoria
Paris

Hotel du Louvre Hotel Le Meurice

I've been asked to add to this list another sublist of nearby hotels. The intended result is:

New York

Hyatt Regency Waldorf Astoria nearby hotels:

hotel 1 hotel 2

Paris

Hotel du Louvre Hotel Le Meurice nearby hotels:

hotel 3 hotel 4

I've got a TableAdapter set up in VS2010 so that I can query the table for nearby hotels with "@town" as the parameter. So at the end of each list of hotels in a town, I need to display the results of this query.

If the query turns up no records (no nearby hotels), I don't want to display anything. If it turns up 1 or more records, I want to display the list of nearby hotels.

I am trying to set up a conditional "if" statement that checks to see if any records returned but am getting an error when I try to build:

Error 3 'Maine_Innkeeper_Site_2010.App_Code.DataAccessLayer.MaineInnsDatasetTableAdapters.membersTableAdapter.GetNearbyProperties(string)' is a 'method', which is not valid in the given context E:Ed dataclientsMaine InnkeepersMIA website 2010Maine Innkeeper Site 2010lodging-search-output.aspx.cs 49 49 Maine Innkeeper Site 2010 [Code]....

View 1 Replies

Forms Data Controls :: Trying To Get A Link To Load A New Page That Passes A Value To The New Page?

Aug 13, 2010

I'm trying to get a link to load a new page that passes a value to the new page. To my dismay I've found out (or im doing it wrong) that this doesn't work in the repeater.

[Code]....

How would i get something like that to work in my repeater so it can show a new News page with more information on it.

View 3 Replies

DataSource Controls :: TableAdapter Null In A Query Parameter

Jan 6, 2010

I am creating a TableAdapter using corresponding wizard, with a GetDataByID() query. The select statement is like this:select * from books where ID = ?Thus books are filtered by ID. But in case a null is passed as a parameter, I want to select all records rather than none. Could you please tell me how I can do it?

View 4 Replies

ADO.NET :: Handle Optional Parameters For TableAdapter Select Query

Dec 15, 2010

I'm creating a webpage with serveral web controls to set search parameters for querying an SQL table. My plan is to use a TableAdapter to hold the query. If the user decides not to use one, several, or any of the web controls to filter their search, I want the SELECT to execute without complaining that it doesn't have parameter values. Should my SQL query look like

[Code]....

View 2 Replies

Web Forms :: Unable To Use HasRows With TableAdapter Select Query?

Nov 30, 2010

I have a TableAdapter that consists of an SQL SELECT query.

Need to create an "if" statement that checks to see if the query returned any records.

Tried "HasRows" but Visual Studio 2010 says: Error 2 'Maine_Innkeeper_Site_2010.App_Code.DataAccessLayer.MaineInnsDataset.membersDataTable' does not contain a definition for 'HasRows' and no extension method 'HasRows' accepting a first argument of type 'Maine_Innkeeper_Site_2010.App_Code.DataAccessLayer.MaineInnsDataset.membersDataTable'
could be found (are you missing a using directive or an assembly reference?) E:Ed dataclientsMaine InnkeepersMIA website 2010Maine Innkeeper Site 2010lodging-search-output.aspx.cs 49 83 Maine Innkeeper Site 2010

What's the proper way to check if HasRows is wrong?

[Code]....

View 4 Replies

Forms Data Controls :: Sequential Delete Statements In A TableAdapter Ad Hoc Query

Mar 24, 2010

VS 2008 ASP.NET 3.5 app connecting to an MS SQL 2005 backend. The app contains a strongly typed dataset with a number of TableAdapters. I'm trying to add a query to one of the TableAdapters that deletes from table A, then related entries from table B, then related entries in the master table - table C. The query looks like this:

[Code]....

When I try to run that query to test it out, an error dialog box pops up that says "Unable to parse query text" followed by a second error dialog box that says "Must declare scalar variable @ID". Will the TableAdapters not run sequential Delete statements like this or did I do something wrong?

**Side note: A cascading Delete foriegn key relationship would be ideal, and was configured on the development database, but the DBAs messed up when replicating the database on the production server and getting them to fix something like this can be a difficult process.

View 2 Replies

Conditional Query String Redirect?

Apr 1, 2011

I'm trying to redirect requests that have a query string to a different domain name.I've got a short url, http://short.url and I want to redirect http://short.url?hello to http://long.url/?hello. So the query string has to be kept by the redirect. To make things more complicated, I would like to rediect http://short.url?hello,hello2 to http://long.url/advanced.aspx/?hello,hello2.Here is the rule I've got now (only dealing with the first part of my question)

<rewrite>
<rules>
<rule name="test" patternSyntax="ECMAScript" stopProcessing="true">

[code]...

However, I am not seeing any redirects. Also, is there a better way to do this? Basically I just want to setup a shortcut to pass queries to a website. These are not meant to be permanent so I'm using redirectType="Found".

View 1 Replies

MVC :: Conditional Styles For Selected Html.ActionLink?

Aug 24, 2010

I am trying to add an item selected class to an Html.ActionLink, I am very new to MVC so its all a bit confusing.So far i have each of my ActionLinks lookins like this

[Code]....

Can any one tell where i am going wrong because the links now fail to respond, basically it isn't checking the condition == Home and if it is then its failing because it doesn't get to the controller.

View 9 Replies

Forms Data Controls :: Conditional Binding Of Selected Value In Formview DDL?

May 4, 2010

I have a sql-bound formview with three DDL's bound to individual SQL datasources. In edit mode, I want to set the selected value to the formview's value, and this works:

<asp:DropDownList
ID="ddl2"
runat="server"
DataSourceID="ddl2lDS"
DataValueField="Name"
SelectedValue='<%# Eval("Name") %>'
/>

But it only works when there's a match between what's in the formview's DS and the DDL's DS.

Unfortunately, there may be instances where the the formview's DS may return a null value or a value different from the DDL's datasource...and when that happens I receive a compilation error like:

'ddl2' has a SelectedValue which is invalid because it does not exist in the list of items.
Parameter name: value

What do I need to do to trap that condition before attempting to set the selected value? Do I need to set the selected value of the DDL in formview's dataBinding or dataBound event, by looping through the DDL and checking for a match first?

View 6 Replies

Web Forms :: How To Pass The Id Of Selected Checkboxes To Another Page Using Query String

Feb 20, 2011

i have used a gridview and checkbox to select the items in the gridview....I can select the values easily...when i am selecting one row at a time then using query string i can easily pass the id of the selected row but when i am selecting multiple rows in the field,i dont know how to pass the array of integers[i.e id value to another field]...

here is a part of my code...this is the html code..

[Code]....

View 3 Replies

How To Set A ListView's Selected Item Based On It's ID In A Query String On Page Load

Oct 6, 2010

Question basically crams it all in... I'm loading a page with a querystring (ID), and I need to use that ID to set the selected item of a ListView when the page loads. The ID is a DataKey on the ListView. I have no code of value to post--none of my attempts at this work.

View 2 Replies

Get Selected Value From Rowlist And Pass It To Query String Laong With Page Number In JqGrid

Sep 24, 2010

I have a row list as [10,20,30] i want to pass the selected row list ie if (20 is selected ill pass that 20 as query string and retrieve the value). and also i want to select the page number too. What are the possible ways to achieve the selected value from row list and current page number and then pass the value to query string.

I tried var Page=$(".ui-pg-input").val()
but it is not firing i think i am missing something out here.

View 1 Replies

Web Forms :: Trying To Add A Hyperlink Column To Gridview That Opens A Page via A Pop-up Window That Passes An ID.  Target="_blank" Won't Work

Jan 22, 2010

I've been trying to add a Hyperlink column to my gridview that opens a page via a pop-up window that passes an ID. Target="_blank" won't work because I need it to be a specific size.

I've been trying to set it up with Javascript functions but DataNavigateURLFormatString takes away the clickablility on the field if you call javascript. NavigateURL seems to work but without an ID passing to the function it will only open one specific webpage.I have also tried Boundfields but have had no success either.This is the closest I have come to getting it to work:

<asp:HyperLinkField
DataTextField="Catalog_Number"
HeaderText="Catalog Number" [code].....

But with the NavigateURL its only displaying the link as is.

View 2 Replies

SQL Server :: Query To Return Conditional Counts Both Distinct And Non Distinct?

Sep 30, 2010

I have the following table structure:

[code]....

The following query returns the default recordset:

[code]....

View 4 Replies

Forms Data Controls :: Conditional In Gridview / Make Some Conditional Statement, When Value "key" Is Changed?

Feb 25, 2010

This might be confusing but ill try to explain the best as i can. I have a gridview that get the data from datatable. This is simulation my grid view.

key data

1 data1

2 data2

2. data2

2. data2

3. data3

3. data3

what i want is make some conditional statement, when value "key" is changed i want to add empty row. so its suppose to be looks like this as result.

key data

1 data1

EMPTY ROW

2 data2

2. data2

2. data2

EMPTY ROW

3. data3

3. data3

View 2 Replies

Conditional ContentPlaceHolder In Master Page?

Jun 24, 2010

I have two master pages in my project, one for web views and another for emails. In the web master page is a placeholder to put page specific JavaScript, if a page is using this and I try to programmatically change the masterpage to send as an email the server falls over as it can't find the placeholder.

Is there a way to change the behaviour so that if a placeholder can't be found it just doesn't include that bit? I'm thinking maybe on my page base class looping over a collection of placeholders and content tags and removing the ones that don't match up, but I'm not sure if there's a good point in the page lifecycle to do this.

I'm using MVC not WebForms if this makes a difference.

View 2 Replies

WebMatrix :: PageData Passes Nulls?

Oct 26, 2010

Caller to Draw.cshtml

if (errors == false)
{
PageData["Range"] = zoom;
PageData["StartReal"] = startRe;
PageData["StartImaginary"] = startIm;
PageData["StartColor"] = startColor;
PageData["N"] = N;
PageData["SizePic"] = sizePic;
@:<img src="@Href("Draw.cshtml")" />;
}

Here all variables have a value, however when arriving in Draw.cshtml the PageData all pass as null.

Draw.cshtml
@{
var zoom = PageData["Range"];
var startRe = PageData["StartReal"];
var startIm = PageData["StartImaginary"];
var startColor = PageData["StartColor"];
var N = PageData["N"];
var sizePic = PageData["SizePic"];
Bitmap bitmap = new Bitmap(sizePic, sizePic);
Graphics g = Graphics.FromImage(bitmap);
Pen myPen = new Pen(Color.Red);
juliaset(zoom, startRe, startIm, startColor, N, sizePic, g, myPen);
Response.ContentType = "image/jpeg";
Response.AddHeader("content-disposition", "inline; filename=test.jpg");
bitmap.Save(Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg);
g.Dispose();
bitmap.Dispose();
myPen.Dispose();
}

View 2 Replies

Using #if Debug Conditional Compilation Statement In Aspx Page

Mar 9, 2010

I am trying to do something like this in an aspx page:

<head runat="server">
<% #if DEBUG %>
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<% #else %>
<script src="jquery-1.3.2.min.js" type="text/javascript"></script>
<% #endif %>
</head>

I get an error "Preprocessor directives must appear as the first non-whitespace character on a line". How can I do this?

View 1 Replies

MVC :: Model Validation Passes In Firefox And It Fails In IE

Feb 14, 2010

I am uploading a JPEG image in an ASP.NET MVC web site.

The model validation fails in IE, but passes in Firefox, when I try to check the mime type of the
HttpPostedBaseFile.

So I debuged it and I found that when using Firefox the Mime type is "image/jpeg" as expected.

When using IE8 the mime type is "image/pjpeg".

Don't say that Microsoft invented a new Mime Type of JPeg images?

View 3 Replies

Response.Redirect Passes The ISAPI_Rewrite Engine?

Feb 12, 2011

So I implement ISAPI_Rewrite on my site. Now i put on my pages a Response.Redirect But as it seems the redirect passes the ISAPI engine.. i.e. I see the new url but the rule doesnt apply.

for example i enter this:
example.com/SomePage.aspx
in SomePage.aspx.cs - PageLoad function theres:
Response.Redirect("/Page");
So I get redirected to example.com/Page

But it says to me "This link appears to be broken"

on httpd.ini I have this rule
RewriteRule ^/Page$ /Page.aspx [L]

My guess is that the Response.Redirect doesnt go through the ISAPI_Rewrite

View 1 Replies

Accessing Function Variables For Conditional Logic In VB Page With Repeater?

May 10, 2010

I have a code behind page with two functions that return two counts (iCount and iCount2). In my repeater table I can display the results of the functions just fine, but now I need to do some conditional logic based on the results of the functions, eg:If iCount =>3 AND iCount2 =>1 Then

View 6 Replies

Web Forms :: Conditional Style Sheets In Master Page URL Rebasing?

Oct 15, 2010

I have two conditional stylesheets referenced in the head of my master page. Because the are contained in conditional comments to show for IE6 and IE7, the relative URL to the css file isn't getting rendered correctly. Is there any way to rebase the URL within conditional comments as can be done for import css references? Current code below:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="xxx_web.master.cs" Inherits="website_master_xxx_web" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB" lang="en-GB">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>xxx website</title>
<link rel="stylesheet" type="text/css" media="screen" href="../css/xxx_web_basic.css" />
<link rel="stylesheet" type="text/css" media="screen" href="../css/xxx_web_structure.css" />
<!--[if lte IE 6]>
&nbsp;<link rel="stylesheet" type="text/css" media="screen" href="../css/xxx_web_ie6.css" />
<![endif]-->
<!--[if lte IE 7]>
&nbsp;<link rel="stylesheet" type="text/css" media="screen" href="../css/xxx_web_ie7.css" />
<![endif]-->
</head>

View 1 Replies

IValidatableObject.Validate Only Called If Property Validation Passes?

Jan 22, 2011

In my model, it seems that Validate() is only called AFTER both properties pass validation.

public class MyModel : IValidatableObject
{
[Required]
public string Name { get; set;}
[Required]
public string Nicknames {get; set;}
public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
{
if(Nicknames != null && Nicknames.Split(Environment.NewLine.ToCharArray()).Count() < 2)
return yield result new ValidationResult("Enter at least two nicknames, new [] { "Nicknames" });
}
}

When a user enters a single line of text in the Nicknames text area but leaves the Name text box empty, only the Required error message for the Name property is displayed. The error message that should be displayed from the Validate() function never shows up.

Only after entering a name in the Name text box and some text in the Nicknames text is the Validate() function called.

Is this how it's supposed to work? It seems odd that a user is shown an error message on a subsequent page when the error is being caused on the current page.

View 1 Replies







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