MVC :: How To Add Maxlength Attribute To MVCContrib Grid Column
Nov 16, 2010
i am working in mvc & using MVCContrib grid to show result in grid format.
I want to add restriction to 1 of the grid columns as not to accept more than 3 characters.
how can i add "maxlength" attribute to MVC Contrib grid column.
Or if any other way
View 1 Replies
Similar Messages:
Mar 5, 2010
I am working on an MVC2 application and want to set the maxlength attributes of the text inputs.
I have already defined the stringlength attribute on the Model object using data annotations and it is validating the length of entered strings correctly.
I do not want to repeat the same setting in my views by setting the max length attribute manually when the model already has the information. Is there any way to do this?
Code snippets below:
From the Model:
[Required, StringLength(50)]
public string Address1 { get; set; }
From the View:
<%= Html.LabelFor(model => model.Address1) %>
<%= Html.TextBoxFor(model => model.Address1, new { @class = "text long" })%>
<%= Html.ValidationMessageFor(model => model.Address1) %>
What I want to avoid doing is:
<%= Html.TextBoxFor(model => model.Address1, new { @class = "text long", maxlength="50" })%>
Is there any way to do this?
View 3 Replies
Feb 2, 2011
I have done listing by using html.grid in my mvc application, need to do sorting How can i do that
View 4 Replies
Jun 21, 2010
I am using MVCcontrib grid in my application. Everything works fine on my dev machine. When I publish it to the server and navigate to the page that renders the grid I am getting this error Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. and the source of the error is shown as <%= Html.Grid(Model).Columns(column => {i have added
[Code]....
to the web.config but still get the error
</textarea></p>
<input type='hidden' name='ID[9]' value='93970' />
<input type='hidden' name='URL[9]' value=[URL]/>
<input type='hidden' name='CAT[9]' value='DataSource Controls' />
<input type='hidden' name='BOARD[9]' value='microsoft' />
<input type='hidden' name='P_DATE[9]' value='Jan 12, 2010 09:43 PM' />
<input type='hidden' name='RANDOM[9]' value='BcIlUOXzN' />
<input type='hidden' name='REPLIES[9]' value='3' />
<input type='hidden' name='USER[9]' value='aziz' />
<p><input class=subject type='text' size='90' name='SUBJECT[9]' value='DataSource Controls :: LINQ using stored procedures and MvcContrib Grid with pagination' /><select name='INDEXED[9]'><option value='1' selected>UPDATE</option><option value='2'>DELETE</option></select>Jan 12, 2010 09:43 PM - Replies: 3 CAT: DataSource Controls<a target=_blank href=[URL]>View</a></p>
<p> <textarea rows=10 cols=100 name='POST[9]' onfocus='setSelRange(this, 0, 0)'/>All,
I have been chasing this erorr all day and coming up blank. I created a stored proceudre(fairly complicated logic), added it to the context, and set the return type to a specific entity type.
It generated this:
[Function(Name="dbo.usp_ServiceTemplateSelectByFkID")]
public ISingleResult<ServiceTemplate> usp_ServiceTemplateSelectByFkID([Parameter(Name="FkId", DbType="Int")] System.Nullable<int> FkId)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), FkId);
return ((ISingleResult<ServiceTemplate>)(result.ReturnValue));
}
I call it from my service with the following method:
public ISingleResult<ServiceTemplate> GetByFkId(int FkId)
{
return Db.usp_ServiceTemplateSelectByFkId(FkId);
}
I have tested the stored procedure and it returns the results I want. When I make the service call from the controller, it doesn't error out, however, it should return 4 records in this instance and instead, it returns the same 4 records (repeating the first record 4 times). .........
View 4 Replies
Oct 21, 2010
Is it possible to override the default 'There is no Data available' message in MVCContrib Grid with a custom message?
View 1 Replies
Jul 6, 2010
In My project i want to use the mvccontrib [URL] to auto generate grid by passing the DataTable to the Grid. Currently Grid does not support this. Grid takes IEnumerable(Of T) and auto generate columns. Is their any way i can achieve this by passing DataTable. Or How do i convert the DataTable to IEnumerable(Of T). My DataTable is completely Dynamic i don't know number of columns or names of the columns at design time. DataTable completely dynamic number of columns are not fixed it just any DataTable. In Short i want to convert Dynamic DataTable to IEnumerable(Of T). Or Is their any better way.
1) One way i tried is using .net 4.0 Dynamic, DynamicObject and ExpandoObject I created a dynamic class as shown here [URL]. I trid passing IEnumerable(Of SampleDynamicObject) but BuildColumns() method is not able to find out the proprieties dynamically added on to it.
2) I think Second way to modify the AutoGenerateColumns() method to work with DataTable, But it looks impossible as Grid Get initialize using IEnumerable(Of T) and all the call on grid for method is using IEnumerable(Of T). So it's come down to converting DataTable to IEnumerable(Of T) and my DataTable are dynamic i don't know their structure at design time So i can't write any specific class to create a object and convert DataTable to IEnumerable(Of T).
View 1 Replies
Jan 12, 2010
I have been chasing this erorr all day and coming up blank. I created a stored proceudre(fairly complicated logic), added it to the context, and set the return type to a specific entity type.
It generated this:
[Function(Name="dbo.usp_ServiceTemplateSelectByFkID")]
public ISingleResult<ServiceTemplate> usp_ServiceTemplateSelectByFkID([Parameter(Name="FkId", DbType="Int")] System.Nullable<int> FkId)
{
IExecuteResult result = this.ExecuteMethodCall(this, ((MethodInfo)(MethodInfo.GetCurrentMethod())), FkId);
return ((ISingleResult<ServiceTemplate>)(result.ReturnValue));
}
I call it from my service with the following method:
public ISingleResult<ServiceTemplate> GetByFkId(int FkId)
{
return Db.usp_ServiceTemplateSelectByFkId(FkId);
}
I have tested the stored procedure and it returns the results I want. When I make the service call from the controller, it doesn't error out, however, it should return 4 records in this instance and instead, it returns the same 4 records (repeating the first record 4 times).
In addition, in my controller code, I am using the MVCContrib ToPagedList() method which doesn't appear to work with the ISingleResult interface (forward only cursor, I'm guessing). I have attempted converting the service results to IQuery, List, and Array, however, I still have the problem with the first record being repeated 4 times.
View 3 Replies
Aug 24, 2010
Is it possible to style the MvcContrib Grid pager to just show "1 2 3 4 ..." for paging?
View 1 Replies
Mar 19, 2010
How to assign MaxLength Property to BoundField column in DetailsView COntrol without Converting into TemplateField.
View 3 Replies
Feb 2, 2011
I have an entity "Order", which contains a set of states. Every state has date and name.
I want show grid with all orders and in grid one column with last state of order. But I dont understand how to do it.
View 1 Replies
Oct 19, 2010
I'm trying to retreive a column value from gridview5 to use it in a query to display resuls in gridview, Also how do you hide a column in the grid?
Where (p.Link_ID Like GridView5.?
[code]....
View 3 Replies
May 27, 2010
i have a grid view with some coulmns like Name,Phone no etc with Edit,Delete column in grid view. I click a row in grid view to Edit,it goes another page where i can edit all fields .Once i update i redirect the page to gridview. I want the grid view to remain in that particular page say 4 of the grid view
View 5 Replies
Mar 21, 2011
I have an existing, mature schema to which we need to add some new Product attributes. For example, we have Products.Flavor, and now need to add new attributes such as Weight, Fragrance, etc. Rather than continue to widen the Products table, I am considering a couple of other options. First is a new Attributes table, which will effectively be a property bag for arbitary attributes, and a ProductsAttributes table to store the mappings (and values) for a particular product's attributes. This is the Entity-Attribute-Value (EAV) pattern, as I've come to understand it. The other option is to add a new column to the Products table called Attributes, which is of type XML. Here, we can arbitrarily add attributes to any product instance without adding new tables.
What are the pros/cons to each approach? I'm using SQL Server 2008 and ASP.NET 4.0.
View 1 Replies
Jul 16, 2010
i need to highlight a column of a grid when clicked for sorting.
View 1 Replies
Jul 26, 2010
I have a boundcolumn that outputs string numbers. I have another column of checkboxes next to it. I need to have it so that when a user checks off a check box the value stored in the string column to the left is then plugged into a function on the server. How can I acheive this?Here is my code:
[Code]....
[Code]....
View 8 Replies
Aug 25, 2010
Has any one ever downloaded and made use of the mvcContrib template gallery for asp.net mvc. I cant find where to download the templates from and there is no documentation for how to use it?
View 1 Replies
Mar 2, 2011
In a classic Tabular MVC View I have put a column that shows or hide some Html.ActionLink() tags for every row, depending on the model.
I was trying to do the same with the razor WebGrid, but not being able to do that.
The code snippet I want to replicate in the grid.Column is similar to this
@if (item.CanDelete)
{
Html.ActionLink("Delete","Delete", new {id=item.id}
}
else
{
Html.ActionLink("Edit","Edit",new {id=item.id})
}
View 6 Replies
Sep 15, 2010
In grid view I want to sort the particular column. For that we have to access that column
How to do this??
View 3 Replies
Mar 9, 2010
Isn't possible to get the latest version of T4MVC without MVCContrib?
If yes where can I find it?
View 1 Replies
Jan 12, 2011
I am using MenuBuilder with code like this:
public static MenuItem MainMenu(UrlHelper url)
{
Menu.DefaultIconDirectory = url.Content("~/Public/Images/");
Menu.DefaultDisabledClass = "disabled";
Menu.DefaultSelectedClass = "current";
return Menu.Begin(
Menu.Items("",
Menu.Action<HomeController>(p => p.Index(), "Home")
),
Menu.Items("",
Menu.Secure<HomeController>(p => p.About(), "About")
),
Menu.Items("",
Menu.Action<RegulationController>(p => p.Index(null), "Compliance")
)/* This is in the Compliance area */
).SetListClass("menu");
}
But I am also using MvcContib Areas and in the code above the final menu item is in an 'Area' called 'Compliance'.
(There are two other areas in the Mvc application and the first in the list of registered areas is called 'Legislation')
What happens is the following:
When a page is rendered (I am using the standard WebFormsViewEngine) the Urls are all rendered using the 'Legislation' area!!?
E.g. http://localhost:1337/Legislation/Home or http://localhost:1337/Legislation/Home/About
and finally http://localhost:1337/Legislation/Regulation
The first two links should not pick up the 'Legislation' area. The last menu item should be in the 'Compliance' area.
How do I prevent the erroneous Area (Legislation) being rendered on the first two links?
How do I get the MenuBuilder markup in the Site.Master to accept an 'area' attribute or get it picked up automatically from the Controller for each link?
View 1 Replies
Dec 9, 2010
I have a rad grid, i have bounded the columns in the grid using GripBoundColumns which shows me dropdown cloumns when i edit the record, Insert/update/delete are working fine for me.
My question is it possible to insert new data into the column(Not the whole record just only to one column) when i edit the record.
For example...
suppose i have 5 columns (Client Name, Account No, Account name, account status, Custodian Dealer) CustodianDealer is my drop down coloumn and data for it comes from different table when i edit or insert a new record in the grid, i can select the existing Custodiandealers in the table.
now if i want to insert a new record to the custodianDealer table not to the grid, how can i acheive it
View 3 Replies
Oct 25, 2010
What im trying to do is have an edit button that instead of opening the line for editing, it forwards you to a page where you can edit. Is this possible? I tried something with the client template, but the grid render is ignoring it completely.
View 1 Replies
Dec 7, 2010
I have one data grid,I want to Hide last entire column of data grid How to do this... Iam using Asp.net1.1
View 1 Replies
Aug 19, 2010
I have a requirement to hide a field called details on a gridview and show it in a jQuery modal dialog when users click on the Customer ID hyperlink. This grid is created programmatically. I will be hiding the details column via the CSS display:none property. Does some one know how can I pass the grid's selected hidden column value to the modal? Here is some of the code I started:
[Code]....
View 3 Replies
May 29, 2010
I have a requirement to build a grid with column header grouping. Each column header of the grid can have nested column. On expanding the column header subsequent columns will be displayed.Is it possible with asp.net grids
View 2 Replies