Make Ol.Order Property Optional (null In Some Cases)?

Dec 30, 2010

I'm using Entity Framework CTP5 (code-first) and I have two classes:

[code]....

and

[code].....

Currently if you create an 'OrderLine' instance, you have to specify an 'Order' instance.

The question: how can I make ol.Order property optional (null in some cases)?

View 2 Replies


Similar Messages:

Web Forms :: Rearranging Texbox Order - Maintain Order In Insert / Update Cases

Jan 23, 2010

I have 5 hard corded texboxes in a page in a sequence with sequence Number . Now i want to add re-order /re-arraning functionaly .. but i can't use ajax reorder list because i have 5 hard corded texbox. how can i maintain the order in Insert/Update cases. And also suggest me control that i can use, another than ajax re-order list. coz i not using any list items i have hard corded items on the page.

View 1 Replies

MVC :: In Second (and Third) Cases I Receive To It Null For Both Parameters?

Jul 5, 2010

I use T4MVC v.2.6.15 I have following problem with registering routes:My problem route is following:

[Code]....

when I use first scenario (with plain mvc rules) my controller

[Code]....

receives empty line and 1 as a parameters. But in second (and third) cases I receive to it null for both parameters.What do I do incorrectly?

View 3 Replies

SQL Server :: How To Set A Optional Parameter To NULL

Oct 29, 2010

I 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]...

View 7 Replies

C# - NLog - Write NULL To Optional Database Column

Jan 28, 2011

I am using NLog for logging in an ASP.Net application and making use of the database target with Microsoft Sql Server.I have some logging parameters that are optional and not always specified. I would like these to be written as null when they are not provided, however NLog seems to always write them as empty strings.

Is there a way to configure it to write null as the default?

Ref: http://nlog-project.org/wiki/Database_target

View 2 Replies

MVC :: Custom Route Returns 404 When All Optional Parameters Are Null?

Feb 19, 2010

I get a 404 error when I navigate to the following URL using the route below:

http://localhost:53999/properties/

However, all the following are correctly routed to the List action in my controller:

http://localhost:53999/properties/usa/new-york/manhattan/12

http://localhost:53999/properties/usa/new-york/manhattan

http://localhost:53999/properties/usa/new-york

http://localhost:53999/properties/usa [Code]....

In PropertiesController.cs: [Code]....

It looks like it should just go to the default controller/action,

View 5 Replies

C# - Make An Entry Field Optional?

Feb 2, 2010

I have made an entry field required somehow but I'm not sure how. When editing a tag, the tag owner entry field should be able to be empty.I have set "allow nulls" in the database table:Does anyone know how I can fix it? To be clear, I want the above form to be submitted without requiring a value for tag_owner.

View 2 Replies

Make A Section Optional With The Mvc Razor ViewEngine?

Feb 4, 2011

I have a Page.cshtml similar to the following (that does not work):

@{
Layout = "../Shared/Layouts/_Layout.cshtml";
var mycollection = (ViewBag.TheCollection as IQueryable<MyCollectionType>);
}
<h2>@ViewBag.Title</h2>

content here

@if (mycollection != null && mycollection.Count() > 0)
{
@section ContentRight
{
<h2>
Stuff
</h2>
<ul class="stuff">
@foreach (MyCollectionType item in mycollection )
{
<li class="stuff-item">@item.Name</li>
}
</ul>
}
}

As I said, this does not work. I want to not define the section if there's nothing in the collection. Is there any way to have something like this work? If not, what are my other options? I'm very new to this Razor ViewEngine. Edit In my layout i have:

@if(IsSectionDefined("ContentRight"))
{
<div class="right">
RenderSection("ContentRight")
</div>
}

what i don't want is the div to output when the section is empty.

View 2 Replies

How To Make Validation Optional For A Complex Type In Mvc

Feb 23, 2011

I want to display an editor for a type User. User contains a field Address of type Address. I made an editor template for the type Address so that it is reusable.

I don't want the field Address to be required for creating a user. But some fields are required for Address, for example country, state etc.

I want to validate Address if I receive any data for it, if I don't receive anything, then I don't want to return any validation error to the UI for Address. I would return only validation errors for User then.

View 1 Replies

MVC :: Model Not Validating Correctly In Controller. Optional Property With Required Children Fields

Oct 30, 2010

Basically I have RegisterModel2 that has a Person class. My requirement is that Phone Number and Address are not required for registration. But if they try to enter a Phone number of Address then it should validate it. Problem is that it is always stating that the child fields of Phone (area code, number) and child fields of Address (street1,city,etc) are required. Is there a way to annotate in the RegisterModel that a parent class is not Required but if any data in a child element is given then and only
then should the child elements be validated?

My Person EDM class has a nullable 0.1 -> 0.1 navigation property to Phone and Address.Here is the person class

[MetadataType(typeof(Person_Validation))]
public partial class Person
{
}

public class Person_Validation [code]....

The Person EntityObject has an optional/nullable Navigation Property to the Phone Object.


The Phone object has these annotations,[Code]....

I have RegisterModel defined as follows:
[Code]....

My View looks like this:
[Code]....

And here is my Controller Action it is posting to:
[Code]....

View 1 Replies

SQL Server :: Make 'providing Data To Parameter In Sproc Optional'?

Feb 3, 2011

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]....

View 2 Replies

Forms Data Controls :: Formview Data - Pulling Data From A SQL Database In Cases The Rows Contain One Or More Null Values

Feb 1, 2011

Using a class component, an Object data source and a formview I am successfully pulliing data from a SQL database. In some cases the rows contain one or more Null values and I would like them to be ignored completely. My simple code follows:-

<%# Eval("add_1") & ","%>
<%# Eval("Add_2") & ","%>
<%# Eval("Add_3") & ","%>

OUTPUT:-

Rose Cottage, 123 New Road, Margate,

View 2 Replies

Forms Data Controls :: Make The Sort Order Reversed?

Jan 9, 2010

I have the following code for a gridview. When I click the Header, it can be sorted by ascending order. But if click the header again , it is still ordered by descending. What I want is that the sort order can be reversed when click the header again. How to do that?

protected void gvList_Sorting(object sender, GridViewSortEventArgs e)
{
DataTable m_DataTable = (DataTable) Session["gvListDatasource"] ;
if (m_DataTable != null)
{

[Code].....

View 2 Replies

Show Dialog In Order To Make The User Able To Enter The Folder Name?

Feb 27, 2011

I have "add new folder" button in my asp.net form and I need to show dialog in order to make the user able to enter the folder name,how can I accomplish that in asp.net?

View 2 Replies

Web Forms :: GridView Sorting - How To Make Sort Order To Change

Feb 16, 2012

Here's my gridview when it comes it it's sorts on Age.  Sorting is available for all columns/headers.  How do I make the sort order to change on the ddsrpt sort to desc order when it's clicked?

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource7" EnableModelValidation="True" Width="789px"
CaptionAlign="Top" Height="126px" BackColor="White" BorderColor="#DCBE68"
BorderStyle="Solid" BorderWidth="1px" CellPadding="4"
HorizontalAlign="Center" CellSpacing="2" Font-Names="Arial"
AllowSorting="True" EmptyDataText="No Records" DataKeyNames="FO,CLMSSN">

[Code] ....

I got this error message - Gridviewsortdirection is not declared

View 1 Replies

MVC :: View Model Property Become Null?

Nov 8, 2010

So I have code as below

public ActionResult Create(AccountClassificationCreateViewModel ACCVM)
{
if (ACCVM.newMtn0130 == null)//Why ACCVM.newMtn0130 is null after [code]...

I wonder why the ACCVM.newMtn0130 become null after RedirectToAction? I already assign with "_ACCVM.newMtn0130 = newMtn0130".

ACCVM._Error didn't become null after RedirectToAction.

View 5 Replies

Cannot Set Property Size Of Null In Chrome?

Mar 11, 2011

I have a good 10 other pages all using the same layout etc all working fine, but I created a new page and cannot get it to work. I have noticed what is causing the error but I don't know why or how to fix it. Have a look at the code below,Its a form with runat=server, Ext.Net Resource Manager, Viewport, Tab Panel and 2 Panels, no code behind. When I load this i get the dreaded this.el is null in Firefox and Uncaught TypeError: Cannot set property 'setSize' of null in Chrome.But alas I remove the form tag and everything works as it should. Now you might say well just remove the form tag, but I cant will add asp.net controls later that needs this tag.

View 1 Replies

MVC :: Error - The 'LastLogin' Property On 'User' Could Not Be Set To A 'null' Value

Oct 26, 2010

I get the following error message when running a LINQ statement to return a User object:

The 'LastLogin' property on 'User' could not be set to a 'null' value. You must set this property to a non-null value of type 'DateTime'.

The User class is generated by Entity Framework. How does one handle setting properties from database fields that are NULL?

[Code]....

The above line of code is the line that errors.

View 8 Replies

Usercontrol Int Property Bind To A Null Value From Database?

Dec 1, 2010

I have build a usercontrol in asp.net, and there is a property like the following.

Everything works fine when the bound value is an integer. However, if the bound field return a null from database, it will return a invalid cast error.

change to a nullable int is not desirable because it changes the how programmer work with the control's property in code-behind.

[code]....

View 2 Replies

C# - Context Is Closed When EF Tries To Access Null Property?

Jan 26, 2011

I have an object defined by my entity framework model that has navigation properties, but whenever the navigation property is null, entity framework seems to try to pull it down again from the database. This is fine for now and I can work on this problem later, but when it tries to get the navigation property from the database, I get the error from the model:The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.

Well this isn't too good that it's blowing chunks like this. Is there anything I can do to ensure that this is only attempted when the context is still open?

View 2 Replies

DataSource Controls :: Passing NULL Dates Through A Property?

Jan 11, 2011

Where do I validate my date values prior to passing them as insert programs ?

I am trying to pass some Null dates.

In my property ?

[Code]....

[Code]....

[Code]....

View 2 Replies

MVC :: Hit Insert Validation Message Showing As'{ Property Name }' Should Not Be Null?

Dec 13, 2010

I have this code..

[code] ...

I am checking this on my telerik grid..I have add new button on my telerik grid when I click add new I can able to insert new record but here my validation message are showing minmum and maximum length perfectly..but if I dint enter anything when I hit insert my validation message showing me as'{ Property name }' should not be null?I dont know why my RequiredMessage is not working on my Empty Textboxes?

View 1 Replies

Forms Data Controls :: ObjectDataSource And DateTime - Set This Property To Null Without Workaround?

Mar 20, 2010

I use FormView with ObjectDataSource and class. I have a TextBox binded to a DateTime? property. When TextBox.Text property is empty i want to set the property of my class to null but the value is 1.1.1 00:00:00. My Workaround:

[Code]....

Is there a way to set this property to null without this workaround? Is this a bug in DataSource or is this a feature by design?

View 1 Replies

Web Forms :: Make The Date Field Null?

May 27, 2010

In the below code when I remove the optional end date and click save it should just take the value as blank, but it doesn't

when I remove the date and click save it saves but still shows the same date as before...when I make it to null it should remain null...how do i do that

#region Save Package
protected void btnBack_Click(object sender, EventArgs e)
{
this.Response.Redirect("/?id=Promotion.PackageList");
}

[Code]....

View 5 Replies

Get Total Row Count And Why Is The GridView's DataSource Property Null In The DataBound Event Handler

Jul 22, 2010

I wanted to get the total row count in a GridView's databound event handler, so I tried the following:

protected void grid_DataBound(object sender, EventArgs e)
{
GridView grid = (GridView)sender;
DataSet data = grid.DataSource as DataSet;
if (data == null)
return;
int totalRows = data.Tables[0].Rows.Count;
}

The problem is that the grid.DataSource property is null. The DataSourceID property is not null, so does that mean that I can't access the DataSource object in the DataBound event handler unless I assign the DataSource property directly?

Edit1: Here is the code in my GridHelper class for adding rowcount to the BottomPagerRow. I would like to get rid of the requirement to pass in the ObjectDataSource, but can't because I need to use the Selected event to get total row count. Hence the reason for the question. I also think this might be better in a custom control where I can access ViewState, and/or create child controls during the Init event (I still have a problem to resolve with the way the pager renders with an extra cell), but then I'd still have the problem of how to get to the total row count when the DataSource itself doesn't appear to be available in any GridView events.

Edit 2: Not really relevant to the specific problem, but I resolved the problem I was having with the pager rendering so i've updated the code posted. I found the trick here: [URL]

#region Fields
private int totalRows = -1;
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="GridHelper"/> class.
/// Adds EventHandlers to the GridView to display results from the ObjectDataSource in the footer.
/// Marked as obsolete because AddResultsToFooter method provides a static access to the same functionality
/// An instance of GridHelper is required by the passed in GridView to store the totalRows value between the two event handlers
/// </summary>
/// <param name="grid">The grid.</param>
/// <param name="source">The ObjectDataSource linked to the GridView.</param>
[Obsolete("Use AddResultsToFooter instead.")]
[EditorBrowsable(EditorBrowsableState.Never)]
public GridHelper(GridView grid, ObjectDataSource source)
{
source.Selected += source_Selected;
grid.PreRender += grid_PreRender;
}
#endregion
#region Event Handlers
private void grid_PreRender(object sender, EventArgs e)
{
GridView grid = (GridView)sender;
if (grid.HeaderRow != null)
grid.HeaderRow.TableSection = TableRowSection.TableHeader;
//Add a cell to the bottom pager row to display the total results
if (grid.BottomPagerRow == null || !grid.BottomPagerRow.Visible)
return;
//Get the control used to render the pager
//http://michaelmerrell.com/2010/01/dynamically-modifying-the-asp-net-gridview-paging-control/
Table tblPager = grid.BottomPagerRow.Cells[0].Controls[0] as Table;
if (tblPager == null)
return;
if (totalRows < 0)
{
//The DataSource has not been refreshed so get totalRows from round trip to client
addResultsToPagerTable(tblPager, grid.Attributes["results"]);
return;
}
int firstRow = grid.PageIndex * grid.PageSize + 1;
int lastRow = firstRow + grid.Rows.Count - 1;
string results;
if (totalRows <= grid.PageSize)
results = string.Format("<span class='grid-pager'>{0} Results</span>", totalRows);
else
results = string.Format("Results <b>{0}</b> to <b>{1}</b> of <b>{2}</b>", firstRow, lastRow, totalRows);
addResultsToPagerTable(tblPager, results);
//Need to store the information somewhere that is persisted via ViewState, and we don't have access to ViewState here
grid.Attributes.Add("results", results);
}
/// <summary>
/// Handles the Selected event of the source control. Gets the total rows, since it is not possible to access them from the GridView.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs"/> instance containing the event data.</param>
private void source_Selected(object sender, ObjectDataSourceStatusEventArgs e)
{
if (e.ReturnValue is DataView)
totalRows = ((DataView)e.ReturnValue).Count;
else if (e.ReturnValue is EntitySet)
totalRows = ((EntitySet)e.ReturnValue).Count;
}
#endregion
#region Private Methods
private static void addResultsToPagerTable(Table tblPager, string results)
{
//http://michaelmerrell.com/2010/01/dynamically-modifying-the-asp-net-gridview-paging-control/
//Get a handle to the original pager row
TableRow pagesTableRow = tblPager.Rows[0];
//Add enough cells to make the pager row bigger than the label we're adding
while (pagesTableRow.Cells.Count < 10)
pagesTableRow.Cells.Add(new TableCell { BorderStyle = BorderStyle.None });
//Add a new cell in a new row to the table
TableRow newTableRow = new TableRow();
newTableRow.Cells.AddAt(0, new TableCell
{
Text = results,
BorderStyle = BorderStyle.None,
ColumnSpan = pagesTableRow.Cells.Count
});
tblPager.Rows.AddAt(0, newTableRow);
}
#endregion
#region Public Methods
/// <summary>
/// Adds EventHandlers to the GridView to display results from the ObjectDataSource in the footer.
/// </summary>
/// <param name="grid">The GridView.</param>
/// <param name="source">The ObjectDataSource linked to the GridView.</param>
public static void AddResultsToFooter(GridView grid, ObjectDataSource source)
{
if (grid == null)
throw new ArgumentNullException("grid", "grid is null.");
if (source == null)
throw new ArgumentNullException("source", "source is null.");
new GridHelper(grid, source);
}
#endregion

View 1 Replies







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