I am using ASP.NET Dynamic Data. The page dynamically creates a List, Edit, Details pages to display the records stored in the table in the DB.
I have the Sub Contractors in the table but I want its visibility set to false on screen.
I've tried
[HideColumnIn(PageTemplate.List)]
[Display(Name = "SubContractor Id", Order = 70)]
public object SubContractorId { get; set; }
ALSO:
[ReadOnlyColumnIn(PageTemplate.List)]
But no joy. Iv made these changes in the database.cs file.
Anyone know how can I make it disappear or remove the hyperlink from it?
EDIT:
[ScaffoldColumn(false)] usually works but because SubContractorId is a FK it seems to not take effect.
Consider the possibility of using Custom pages (List and other) for your Dynamic Data site which allows you hide specific fields.
For more information: How to: Customize the Layout of an Individual Table By Using a Custom Page Template
Related
Note: I only need to use Dev Express controls and I am using windows forms with dotnet framework 3.5
Below are my requirements
I need to display multiple check-in check-out entries with time as displayed in the screen shot and also reason specified below each check-in checkout entry.
I need to display a edit icon for each row when user clicks on the edit icon a time picker need to populate and user can modify the time and the list box time need to modify
I need to display a delete icon at the last entry when user deletes the last entry the delete icon should display to the above entry.
I have CheckinCheckOut button which need to add the data to list box in the same format which i have displayed the image
Which control should i use to complete all the above requirements?
If it is list box control for the above requirement can you please provide me a sample which satisfies all the conditions of the requirement.
Please provide a sample with the below requirement
Looks like this could be done with the GridControl. Checkin/Checkout statuses can be a column, the check-in/check-out time would be a second column and the delete/edit icon can be a third, unbound column. The reason (initial check-in, meal break, check-out etc...) could be done by binding the GridView's Row Preview Section to another field in the data source.
For instance, a simple data source such as:
public class EmployeeCheckIn
{
public enum CheckInTypes { CheckOut, CheckIn };
public CheckInTypes CheckInType { get; set; }
public DateTime CheckInTime { get; set; }
public string CheckInReason { get; set; }
}
Your GridControl could be bound to a List instance, having column 1 bound to CheckInType, column 2 bound to CheckInTime and the preview row bound to CheckInReason.
The unbound column with the edit button can make use a RepositoryItemButtonEdit control in which the text box is hidden, the ButtonKind property is set to Glyph and an "edit" image is supplied to draw the icon. Handle its ButtonClick event to invoke your edit mode.
When adding a new view to an ASP.NET MVC 5 project using the Add View dialog pictured below, I'm invited to choose a template and a model class, which allows me to quickly generate a form for creating new instances of the model or a view that displays the model's properties. But why should the view care what the data context class is? In my project, whether or not I specify the data context class, the same view is generated, but I'm guessing there's a scenario where it would make a difference. What might that be?
If you refer to an existing DbContext then the wizard will insert public DbSet<Employee> Employee { get; set; } (if it doesn't already exist) in your DbContext derived class . Looks like Visual Studio doing some of the leg work.
I want to create a custom editor Content Template for a property on our view model that corresponds to a Birthdate, which is really in the database a simple smalldatetime object. I'm hesitant to simply override either the standard Date or DateTime, because this is a large project and I don't want to force the behavior everywhere.
Is it possible to add either a new DataType to the DataAnnotations collection of Birthdate, or are there some tags that I've yet to find so that I can direct that property to use a specified Editor and Display content template?
public class MyModel
{
[UIHint("BirthDate")]
public DateTime BornOn { get; set; }
}
Then, in Views/Shared/EditorTemplates, create BirthDate.cshtml. The EditorFor will use that editor template instead of the DateTime.cshtml editor template.
I'm working on a website that will allow instructors to report on the academic progress of students in their classes. I've got the website set up two primary pages: one with a user control that displays the classes (a GridView of basic class info with a child GridView in a template field that displays student names and checkboxes to select them -- called MiniStudents), and another with a user control that displays the selected students -- called FullStudents.
Although improbable, it's possible that an instructor could have the same student in two separate classes. I've already accounted for this in the current page setup -- the combination of student ID and class ID (class IDs change each quarter, for those thinking this will be an issue) form a unique key within the database. Recently, one of my users asked if I could break records out by classes on the page, so that instructors would be able easily recognize which class they're operating in.
So, my question is this: is it possible for me to dynamically add a column to the end of the class user control that would allow me to switch out MiniStudents for FullStudents?
If I've left out any important details or if anyone wants/needs code, please let me know.
Try this:
//Under page_load
string path;
if(condition) path = "~/MiniStudents.ascx";
else path = "~/FullStudents.ascx";
Control userControl = this.LoadControl(path);
panel1.Controls.Add(userControl);
And if you have specific properties that you want to set before the usercontrol gets rendered then make them inherit a custom usercontrol class:
public class CustomControl : UserControl
public class MiniStudents : CustomControl
public class FullStudents : CustomControl
So then you can do this:
CustomControl userControl = (CustomControl)this.LoadControl(path);
userControl.UserId = userId;
I hope this helps!
You could add both, and hide one or the other.
You could use a multiview control to control which control is visible. Though I would be concerned about your viewstate size if you are loading all these controls simulantously. It sounds like there could be a lot of data and markup on the page.
I have an object that I set as the datasource for a gridview - this works fine, I get a nice table on the page with a column for each public property.
But - I always want to hide one of the columns (but still need it available as a public property.
I'm using a clunky hide-column-on-row-created fix for now, but am looking for a better solution, like an attribute applied to the property to hide it from databinding.
Apparently this exists in winforms:
[Browsable(false)] // this stops Type from showing up in databound controls
public string Type { get; set; }
public string Description { get; set; }
Can anyone suggest a similar solution for ASP.NET?
Update:
I marked Rex M's answer as correct, because it answers the question, but if anyone else is interested in how to do this:
What eventually worked for me was to mark the property corresponding to the column I wanted to hide as internal instead of public.
Looking at the reflected code for GridView.CreateAutoGeneratedColumns(PagedDataSource dataSource), it appears there are not any checks for attributes when it is scraping the datasource for properties. So, apparently not.