VS 2008 - How To Declare Optional Parameter In C#
Jul 24, 2010I want to declare Optional Parameter in C#.As in VB.Net we have OPTIONAL Keyword,In C# is there any way or we have to pass all the arguments in C#?
VB.NET CODE
[code]....
I want to declare Optional Parameter in C#.As in VB.Net we have OPTIONAL Keyword,In C# is there any way or we have to pass all the arguments in C#?
VB.NET CODE
[code]....
I have the following scenario: my website displays articles (inputted by an admin. like a blog).So to view an article, the user is referred to Home/Articles/{article ID}.However, the user selects which article to view from within the Articles.aspx view itself, using a jsTree list.So I what I need to do is to be able to differentiate between two cases: the user is accessing a specific article, or he is simply trying to access the "main" articles page. I tried setting the "Articles" controller parameter as optional (int? id), but then I am having problems "using" the id value inside the controller.
View 7 RepliesI have got a problem about setting the optional parameter to NULL in sql sp. Initially I set all the parameters null in the sql sp. That's OK. But I would like to set the parameters to Null again if a particular parameter has a value of - 1 by using the "IF ELSE" statement block. However, the problem was that I was unable to set the parameter to NULL in the IF ELSE statement. So please correct my IF ELSE statement in the store procedure. This is really urgent and important for my project.
spGetMealsByNutritions]
@MealTypeID Int,
@Gluten Bit = Null,
@Dairy Bit = Null,
@Egg Bit = Null,
@Fish Bit = Null,
@Veg Bit = Null,
@Pork Bit = Null,
@Beef Bit = Null,
@Soy Bit = Null,
@Sesame Bit = Null
[code]...
I'm starting a port of an existing ASP.NET Web Forms CMS to ASP.NET MVC and want to get the routing right from the start.Note: it isn't important to have the exact same URL structure.I think this answer is close to what I'm looking for but would like some additional input should anyone have it.
?Content=News/CurrentNews/This_is_a_news_article
?Content=Corporate/About_Us/Overview
[code]...
am to add optional parameter to pass these in a method the parameter may vary every time.And i need to pass these parameter to a method, so my question is how should i add these optional parameter to a collection and what kind of collection object should i use and how should i use that.
View 1 RepliesI am getting return some data through stored procedure in a asp.net 3.5. Below is the method.
public DataSet GetDataSet(string strConnection,string strSPName, string param1)
{
DataSet ds = dataAccessLayer.getDataSet(strConnection, strSPName);
return ds;
}
In some cases, I have to pass 3-4 parameter. How can we do pass optional parameter here....
I would like to have two different welcome pages for a site.How could I handle this? I've looked at routing but I'm not sure if global.asax.cs is the correct place to place this into.
www.mycompany.com should display generic information. Displaying view Home/Default.aspx
www.mycompany.com?id=1 should display welcome customer x. Displaying view Home/Welcome.aspx
I was expecting a parameter will become a empty string value if the parameter is missing, but it turn out to be null. have I done it wrong for the optional parameter?
[Code]....
I have the following routes setup in my route config file. I have a config reader that maps these to MVC-style routes.
[route name="customers" url="customers/{statename}/{marketname}/{pagenumber}"]
[controller name="Customers" action="Display" //route]
[route name="pcustomers" url="{customername}/customers/{statename}/{marketname}/{pagenumber}"]
[code]...
i have a stored procedure with multiple parameters. and several statement which utilities a specific set of queries. therefore, every time its not necessary data will be passed through the parameters, so how can i make "providing data to parameter" optional
My stored procedure:
[Code]....
I'm creating a reports with the following filter criteria:
ID - textbox Created Date - range between start and end date Syste Name - dropdown Users may filter the report based on the ID or System Name or all the criteria mentioned.
The search Field for ID, by default has a Null checkbox beside on it while other filter doesn't. how can I enable the checkbox for the other filters?
So I came across this article which should my issue. Apparently, I'm receiving a formula error "The arguments to the following functions are not valid:FIND" with this formula OR(FIND(Creation Date, Parameter: Creation Date)<>0, Parameter : Creation Date = Empty). see this link for the screenshot. I don't know what I'm missing. I'm using Reporting Services 2005
I´m in need to export datagrids to excel. I found a good solution in C#. I´m a newbie at VB.net. I have got it to work but I´m not familar to set the SQL connection and bind data in C#.
I need to declare my query with a calendar parameter but I have no idea how this should be done in this code.
Either, how do I set parameters into the C# code or how can I set a SQLDATASOURCE in the ASPX file and still run all code.
ASPX CODE
[Code]....
And CS
[Code]....
I have an sp that I would like to us the data from one column to use as a parameter for the following Select Statement
[Code]....
need to set the @customerID parameter = customer_data.CustomerID from the first Select Statement
I'm trying to have a parameter as optional i.e. /Category/{ProductName}/{ProductOption} where ProductOption is optional. How do I handle this in web forms 4? Here's what my code looks like now:
[Code]....
I have reportviewer control on my page, i manged to add a parameter to my report, but i don't know how i can pass parameter value to the report.
View 3 RepliesI'm using a user control which uses a dropdown. I call a parameterized stored proc to to populate it. I don't know how to pass parameter '_ReportName' from main aspx file to ascx file.
HTML Code:
<asp:DropDownList ID="dropSortOptions" Width="200px" CssClass="Dropdown" runat="server"
DataSourceID="sqlDataSource" DataTextField="Option_Desc" DataValueField="Option_ID"
AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="sqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringName %>"
SelectCommand="sp_SortOptions" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:ProfileParameter Name="ReportName" PropertyName="_ReportName" />
</SelectParameters>
</asp:SqlDataSource>
I am in a situation where i need to reserach on a reporting tool, Other than SSRS for a good interface, cool features like having parameters with AJAX like intellesence. Please advice on the toold that are available currently that could be available and worked with an MVC .net application.
the features i am looking for in a report are:
Ajax intellesence when i search the Student name...
interactive Sorting
Graphs, Pie, maps
Either or parameter passing into the report, with SSR we have to provde all the parameters or it wouldnt let us run the report
Dashboard reports......
I have ajax control toolkit in bin folder ,i have win 7 inmy system but still i m getting this error ..
Could not load file or assembly 'AjaxControlToolkit' or one of its dependencies. The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))
I'm using Visual Studio 2008 Query Builder and am trying to pass a value to a parameter that uses the IN OPERATOR.Here is my sql from qb:
SELECT COURSE_TITLE, INSTR_NAME, ADMIN_UNIT
FROM vwHRIC_EC_ContractSummary
WHERE (ADMIN_UNIT IN (@ADMIN_UNIT))
The trouble I am having is that if the parameter @ADMIN_UNIT contains more than one value such as (8X, CV) that the query doesn't return any data. If I run the same query with only one value such as (8X) it works fine.I have tried different formats like (8X, CV), ('8X', 'CV'), (8X; CV) but none have worked.I ran this same query in SQL Server Management Studio and and it returns data no problem but can't get it to work in Query Builder for my aspx application.Does anyone have any experience with this problem and how did you correct it?
I have an MVC action on my abstract BaseControlller like this (and this action is common across all inheriting controllers):
//
// GET: /controller/RenderForm/{formType}
[Authorize(Roles = "Administrators")]
public ActionResult RenderForm(FormType formType, BaseContentObject contentObject)
[code]...
Is it possible to do an optional join as follows?:
private void OptionalJoin(string phrase)
{
from t in db.Table
// (if phrase != string.Empty then) join t2 in db.Table2 on t.Id equals t2.Id
select t
}
Although I'm aware that I can copy/paste this and move the conditional logic outside the query, the query is ~200 lines and there are 4 different optional joins I would like to incorporate, so it would get messy and be difficult to maintain. I'm looking for a clean, streamlined way to do this.
I want to create a method with optional parameters in my wcf service. I am doing it like this
[Code]....
When I try to use it in my client application and try to pass the values only for first two parameters it gives me an error that"Argument not sepecified for parameter Status"
Wondering if you could give me a nudge in the right direction. I'm working on an app where I need to validate a field for a correct URL. However, this is an optional field and may be left blankI was just wondering, how can I bypass the validator if the field is null.
View 5 RepliesWhat is the best way to handle following situation? A dropdown(for master table) is optional in a particular form. But, In database table the field is constrained with foreign key. If user don't select from dropdown then It creates problem because of foreign key. One solution is to create default option in master table and use it in case of blank selection. but in dropdown, we need to handle this to show on top. Is it perfect solution?
View 1 RepliesI have a timespan ts that has mostly minutes and seconds and sometimes hours. I'd like to format a string that'll give these results depending on the data
3:30 (hours not displayed, showing only full minutes)
13:30
1:13:30 (shows only full hours instead of 01:13:30)
So far I have
string TimeSpanText = string.Format("{0:h\:mm\:ss}", MyTimeSpan);
but it's not working.