.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Need help with conditional sql

Posted By:      Posted Date: September 28, 2010    Points: 0   Category :ASP.Net

environment:  VWD 2010 Express, VB, SQL 2008 Express, .NET 4.0

Hello - I need some help understanding what's going on with my SQL.  I have a listview that pulls data from a Tasks table.  Inside the listview cells is a TaskID (among other stuff).  That TaskID exists in a CrossRef table 0 or more times.  The CrossRef table includes Task1 (TaskID), Sequence, Task2 (TaskID), Active, and XRefID.  So Tasks.TaskID could possibly be used as CrossRef.Task1 or CrossRef.Task2 but not both in the same row. (that all works fine)

In my listview I display the text "XRef" if that particular taskID exists anywhere in the CrossRef table - that also works fine.  What I would like to do is display the cross reference information when XRef is hovered over.  I can get the entire table to come back as a hover but cannot seem to isolate the results to only the rows that match the TaskID.

I have tried this for my SqlDataSource:

    <asp:SqlDataSource ID="SqlXRef" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        SelectCommand="SELECT T1.Responsible, T1.Task AS Task1, C.Sequence, T2.Responsible AS Responsible2, T2.Task AS Task2 
         FROM CrossRef C 
        INNER JOIN Tasks T1 

View Complete Post

More Related Resource Links

Using Conditional Split data Transfer in SSIS 2008

This article uses the Integration Services Conditional Split Data Transformation element to filter and transfer data from a set of flat text files to SQL Server database table. The concept can be easily extended to apply to any other source or destination such as Microsoft Excel. This scenario is useful in creating denormalized database tables in a reporting and analysis situation.

Inline conditional output


Is it possible to somehow output some content based upon some conditional check in Razor? If not, I hope this possibility will be added in the future. What I want to do is the following:

<option value="1" @if(ListMode == 1) { = "selected=\"true\"" }>Full list</option>

As I can't figure out a way to do this, I have to either make a helper that does it for me or write duplicate code.

Web Set-up Project Conditional Dialogs


Hi all,

I'm currently putting together a web set-up project to deploy a web site on a customer site. What I'd like to be able to do is have different routes through deployment depending on the installation technicians response.

For example asking: Use existing or create new membership database? Then depending on the response prompting for database location etc.

Not sure if this is possible with web set-up projects. I understand about adding custom actions and additional dialog boxes, but cant quite understand how to add custom dialogs, or conditional dialogs.

Can anybody point me in the right direction?


Cutting Edge: Conditional Rendering in ASP.NET AJAX 4.0


Last month, Dino covered the basics of the new DataView client control and the binding techniques most commonly used. In this article, he goes one step further and covers conditional template rendering.

Dino Esposito

MSDN Magazine November 2009

Is Conditional Subscription possible in SSRS 2005?


Hi Guys,

Is there a way to set up a subscription that will send e-mails based on the contents of a report? For example, I want to schedule a daily subscription that will only send an e-mail if the report contains data, otherwise it will do nothing for that day. i.e If the report has more than one row, it should send the mail otherwise it should not send the mail.....

Is it possible in SSRS 2005 or is there any other way to do it???


Conditional styles for selected Html.ActionLink


Hi, 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

<li><%: Html.ActionLink("Home", "Index", "Home", new { @class = ViewData["current"] == "Home" ? "selected" : "" })%></li>

And in the controller i have

public ActionResult Index() {
            ViewData.Add("current", "Home");
            return View();

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.

Any ideas would be appreciated


Conditional alert box in view


When a view is shown, base on a simple conition in the model (Model.RenewalDate < DateTime.Today), I need to pop up an alert box saying 'Membership renewal is overdue'. There's no process required beyond that. Just a simply popup information box, then continue as normal.

I know the java to create an alert, or I could use the jquery modal, not bothered, but I can't work out the code in the view (yeah, I know logic doesn't belong in a view, but this really is a view concern as there's no functionality required beyond the message).

Razor. Conditional Rendering.



I am using Razor and I need to display a String or the view property value on the following condition:

@if(String.IsNullOrEmpty(View.Title)) { @("Default Title") } else { @View.Title }

This is working. But can I make this simpler?

I tried the following:

@String.IsNullOrEmpty(View.Title) ? @("Default Title") : @View.Title

This is not working ...



Conditional Validation



i have been looking for a way to conduct conditional validation for a web page i am developing and it seems like there isnt a real clear cut way to do this dynamically. from what i can tell a validation method could be developed in the aspx.cs file that is called to make sure the required fields are filled in for particular cases, but is there any other way? i was hoping to do it dynamically (as i mentioned before), does anyone have any examples i could look at?

here is what i am trying to accomplish:

There will be a drop down box, if a certain value is selected from that drop down box, another drop down box then becomes a required field. if any other value is selected then the other drop down box is only optional.

I also have another situation where i have a drop down box, when a certain value is selected, their must be input in the text and dropdown boxes next to it (it would be pretty cool to hid the boxes until needed but i am not sure how hard that would be). if any other value is selected from the drop down box, no input can be excepted in the other two fields.

Thanks for that help!

XML Repeater Inside Conditional Statement


Hi all,

I'm working on an VB.Net application which have 2 nasted repeaters using xml as data source. I need to add a conditional statement withen the first repeater ItemTemplate as follows:

	<%# IIf(XPath("@type")= 3 , "<html>", "<div id=""tblPages"" runat=""server""><divsub""><h2>"   &  XPath("@title") &  "</h2><ul class="sublinks"><asp:repeater id=""rpPages"" DataSource=""XPathSelect("@page")"" runat=""server""><ItemTemplate><li></li></ItemTemplate></asp:Repeater></ul></div></div>" ) %>

The problem come when I  try to add the

DataSource='<%# XPathSelect("page") %>'

so I get an error.

Does anyone have idea if the above code may work?

thank you

Conditional Report Conditional Field


I want to dispaly NILL if a Field Contain NULL value

(Data is coming from database)

Conditional Compilation Symbols?

Hi,I want to know more about the conditional compilation symbols in a class library.Regards,ap.

Conditional VB.NET Subs

Hi Guys, I have a setup where I have many different Add forms linked to a single .aspx.vb file for the purpouse of easy maintenance. The issue I have run into is that a few forms have a few extra controls than the other pages, so when I go to compile the pages without these controls, it throws the error "BC30506: Handles clause requires a WithEvents variable defined in the containing type or one of its base types." for Subs linked to the events button clicks, etc...  Is there a way to make subs apply to only one calling aspx page and be ignored by the others? If not, does anyone have any other solutions? Thanks, Mike Marshall  

Conditional Sum in Crystal Reports

I need to sum (count ) no records based on codition how can do that

How do you calculate a value in one list from the conditional adding of values in another list ?

I have a list (call it my first list) with a attribute of Initial Estimate (Hours) and a unique ID and want to conditionally search for that unique ID on another list (second list) and aggregate the Initial Estimate (Hours) on the second list to arrive at single value for my first list! Any ideas on how to do this?

conditional update a column base on multiple result

Hi, I have a requirement that to conditional update a column base on the table result within a single update statement.     declare @TableStageStatus table ([OldTable] [varchar](100) NULL, [OldKey] [varchar](100) NULL, [StatusCode] [varchar](10) NULL) declare @Table table ([Key] [varchar](100) NULL, [row_stus_cd] [varchar](10) NULL) INSERT INTO @TableStageStatus ([OldTable],[OldKey],[StatusCode]) VALUES ('a' ,'1','I') INSERT INTO @TableStageStatus ([OldTable],[OldKey],[StatusCode]) VALUES ('a' ,'1','I') INSERT INTO @TableStageStatus ([OldTable],[OldKey],[StatusCode]) VALUES ('a' ,'1','E') INSERT INTO @TableStageStatus ([OldTable],[OldKey],[StatusCode]) VALUES ('a' ,'1','I') INSERT INTO @TableStageStatus ([OldTable],[OldKey],[StatusCode]) VALUES ('a' ,'2','E') INSERT INTO @TableStageStatus ([OldTable],[OldKey],[StatusCode]) VALUES ('a' ,'1','E') INSERT INTO @Table ([Key],[row_stus_cd]) VALUES ('1',null) INSERT INTO @Table ([Key],[row_stus_cd]) VALUES ('2',null) UPDATE A SET A.row_stus_cd = case when row_stus_cd is null then B.StatusCode when B.StatusCode='E' then 'E' else B.StatusCode end FROM @Table A INNER JOIN @TableStageStatus B ON A.[Key]=B.OldKey and B.OldTable='a' WHERE B.StatusCode in ('E','I') select * from @Tab

Problem with conditional comment

I have this conditional comment that is used to call a different style sheet for IE7.  I can't figure out why it won't work though.Everything seems to be right.  The file name and path for the IE 7 style sheet are correct.  This has been proven because the other style sheet works and it's in the same folder.Does anyone see what is wrong with it?<head runat="server"> <title></title> <!--[if IE 7]><link href="styles/styles_ie7.css" rel="stylesheet" type="text/css"><![endif]--> <link href="styles/styles.css" rel="stylesheet" type="text/css" /> <asp:ContentPlaceHolder ID="head" runat="server"></asp:ContentPlaceHolder> </head>
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend