Mvc DataAnnotations How To Make Field No Editable In 3.5

May 20, 2010

I have a few field in my entity that i wish to be non-editable. Looking in the docs it seems like "EditableAttribute" would do the trick. However this is only 4.0Just wondering if there are other attributes that would have the desire effect. So be clear, i have a field called "DateRegistered" i wish to display this as string not text field using "Html.EditorFor"

View 2 Replies


Similar Messages:

Adding CSS Class To Field From DataAnnotations MVC 3?

Feb 2, 2011

Is it possible to add a CSS class from DataAnnotations (metadata) when I use Html.EditorForModel() - without a custom template...

Something like this [DataType(CssClass = "DateTime")]

public class TestInput
{
[Required(ErrorMessage = "Name is required.")]
public string Name { get; set; }
[Required, StringLength(500)]
[DataType(DataType.MultilineText)]
public string Description { get; set; }
[Required]
[DataType(CssClass = "DateTime")]
public DateTime Date { get; set; }
[HiddenInput(DisplayValue = false)]
public int Id { get; set; }
}

Here is a link to what I am referring to: [URL]

View 1 Replies

C# - Make Exported .XLS File Editable?

Mar 4, 2010

How to make exported .XLS file Editable Thid code makes .XLS File Read Only

:(
using System;
using System.Data;
using System.Configuration;
using System.IO;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class GridViewExportUtil
{
/// <param name="fileName"></param>
/// <param name="gv"></param>
public static void Export(string fileName, GridView gv)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AddHeader(
"content-disposition", string.Format("content-disposition", "attachment; filename={0}", fileName));
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Charset = System.Text.Encoding.Unicode.EncodingName;
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.Unicode;
HttpContext.Current.Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble());
using (StringWriter sw = new StringWriter())
{
using (HtmlTextWriter htw = new HtmlTextWriter(sw))
{
// Create a form to contain the grid
Table table = new Table();
// add the header row to the table
if (gv.HeaderRow != null)
{
GridViewExportUtil.PrepareControlForExport(gv.HeaderRow);
table.Rows.Add(gv.HeaderRow);
}
// add each of the data rows to the table
foreach (GridViewRow row in gv.Rows)
{
GridViewExportUtil.PrepareControlForExport(row);
table.Rows.Add(row);
}
// add the footer row to the table
if (gv.FooterRow != null)
{
GridViewExportUtil.PrepareControlForExport(gv.FooterRow);
table.Rows.Add(gv.FooterRow);
}
// render the table into the htmlwriter
table.RenderControl(htw);
// render the htmlwriter into the response
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
}
}
/// <summary>
/// Replace any of the contained controls with literals
/// </summary>
/// <param name="control"></param>
private static void PrepareControlForExport(Control control)
{
for (int i = 0; i < control.Controls.Count; i++)
{
Control current = control.Controls[i];
if (current is LinkButton)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as LinkButton).Text));
}
else if (current is ImageButton)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as ImageButton).AlternateText));
}
else if (current is HyperLink)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as HyperLink).Text));
}
else if (current is DropDownList)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as DropDownList).SelectedItem.Text));
}
else if (current is CheckBox)
{
control.Controls.Remove(current);
control.Controls.AddAt(i, new LiteralControl((current as CheckBox).Checked ? "True" : "False"));
}
if (current.HasControls())
{
GridViewExportUtil.PrepareControlForExport(current);
}
}
}
}

View 1 Replies

Web Forms :: GridView - How To Make Editable Columns As Dropdownlistbox

Mar 24, 2011

I have an editable GridView and I would like to add dropdownlistbox for editable columns. Is there a way to do it? I want to bind the data also so the dropdownlistbox comes with values.

Here is a sample source code:

[Code]....

View 3 Replies

Forms Data Controls :: How To Make Editable Gridview

Feb 28, 2010

I want to make an editable gridview with 4 boundfield. When a row is selected, I want to edit the value of the 2 boundfield. Can I use edit, update commandfield?. Because when I tested it, all the columns of the selected row becomes editable.

View 4 Replies

How To Make A Readonly Text Box Editable On Mouse-over Using J Query

Aug 15, 2010

I have a read-only text-box with text in it. How to make it editable on mouse-over using J query ?

View 1 Replies

C# - Make A Specific Column Editable Upon Clicking Edit?

Jan 22, 2011

I have a gridview with "Edit Update Cancel" command field. When I click Edit, all the columns in the particular row becomes editable. I just need to have 2 specific columns editable. How is that made possible ? (Screen Shot Attached) [In the screen shot all 3 columns are editable, I just need the second and third to be editable]

View 2 Replies

Forms Data Controls :: Set Width Of Editable Field In GridView?

Dec 9, 2010

I have set up an editable GridView using the AutoGenerateEditButton property. When the Edit link generated is clicked I only get a small editable area, is there a way to customise this to show more text?

View 2 Replies

Forms Data Controls :: Make A Gridview Editable Programmatically - Per Row

Nov 3, 2010

I have a gridview with bound fields and a templateField that receives data from a submit button which, depending upon the selected object, i.e. dropdown 1, 2, or 3, return a result set. The gridview also has a checkbox column which is used as a marker to determinie the rows to be added to and existing table. If a user selects multiple row, those rows are written to the database. Everything works.

Now, I need to add additional functionality to the gridview:

Upon selecting the checkbox, programmatically the accompanying row must become editable; for each row presented.

Deselected the checkbox, return the gridview row to a read-only state.

There are 14 columns, one of which is a dropdown which needs to maintain its default value.

View 1 Replies

Forms Data Controls :: Make Editable Grid View

Sep 21, 2010

i have created an application which shows records from the database i have to make my grid view editable so that it will reflect into the data base

View 17 Replies

Forms Data Controls :: Make Gridview Row Editable On Redirect

Jan 7, 2011

I have two pages; one page similar to a 'dashboard' displaying an incoming correspondence gridview and the other page 'incoming' displaying the same gridview of incoming correspondence. So my dashboard page is just a snap shot of what some pages have. So there are main pages that are being summarized in the dashboard. What I want to do with the Incoming gridview in the 'Dashboard' Page is once a user clicks a row in that gridview it obtains the correspondence id and redirects to the Incoming page and make that row in that gridview(same view or query as the gridview in the dashboard) editable.

What I have right now is I am obtaining the correspondence id for the row selected and redirecting to the Incoming page but have noo idea how to make that row editable in the gridview in the Incoming page.

View 5 Replies

JQuery :: Make All Columns Editable At Same Time Of A Row Via Jeditable Plugin?

Dec 7, 2010

i am working with jeditable plugin in MVC ,what I'm trying to do is click a button and all the fields a certain row become editable and automatically go to their editable state.. so, in other words, I have a table, I want to click Edit on the side of a row and all the columns in that row become editable .

View 1 Replies

How To Make GridView Column Read Only / Editing Whole Row Of The Grid Is In Editable Mode?

Jun 2, 2010

I am using Gridview and on that data is binded conditionally.the problem is that at the time of editing whole row of the grid is in editable mode and i want only few of the columns editable. my code is as follows

[code]....

View 4 Replies

Forms Data Controls :: Make Editable Gridview - Add - Update - Delete

Feb 24, 2010

I've got my data in the gridview via:

[Code]....

Now I need to make all the data editable (add, update, delete). Why isn't the Gridview the same as DataGridView? With the DGV, the data showed EXACTLY as it did in the database and one could add a record, edit a record, or delete a record.

View 2 Replies

Forms Data Controls :: Binding A Gridview From Session - Make Editable

May 31, 2010

In my project i am binding a gridview from session and i want to make it editable. i handled the rowediting,rowupdating and cancelediting event as suppose to and at run time i bound my data to the grid cells in the rowdatebound like this

if (e.Row.RowType == DataControlRowType.DataRow)
{ RequiredPaper paper = (RequiredPaper)e.Row.DataItem;
e.Row.Cells[0].Text = paper.PaperDesc;
}

and every time i click on the edit link in the grid view the cell never turns in the edit mode so i can not edit it!

View 4 Replies

Forms Data Controls :: Gridview - Make All The Row Editable When User Click This Button

Aug 25, 2010

I am working in a asp.net page, Where I have a button "Edit Grid". I would like to make all the row editable when user click this button.

View 4 Replies

Forms Data Controls :: Make Gridviews And Labels Into Non - Editable Single Report

Jan 24, 2011

I have 3 gridview,4 lables having the information, i have a button(Report), when i click this i want make this as Non-editable format single report. i have seen converting Webform to PDF but we should fall back to 3rd party tool to produce the report.

View 4 Replies

Forms Data Controls :: How To Make Number Of Editable Columns Of Gridview Depends On A Textbox Value

Oct 4, 2010

I have a Gridview with 12 columns, Jan, Feb...Dec.

I have a textbox value that could be 1, 2,...12

I want if textbox value is 7, then column Aug-Dec in Gridview is editable when in update mode and the column in Jan-Jul is not updatable (eg make it label instead of textbox).

How can I do this ?

View 3 Replies

Forms Data Controls :: Make Gridview Rows Editable On The Click Event Of A Button

Sep 20, 2010

How to make gridview rows editable on the clilck event of a button.

View 3 Replies

Forms Data Controls :: Editable Gridviews - Updating Rows Not Editable / Bound

Jun 30, 2010

Note: Code is taken from this tutorial [URL] I currently have an editable gridview with only some columns editable by the user. In the background I want to record the time/date they have saved the data to the grid. This column 'Time' is not bound to the grid. Is there anyway I can still include this update when rebinding the newly edited data?

I'm also having a problem saving the updated data of my column ActivityTotal. I've been debugging that and following the variable, and it holds the correct value, but just doesnt seem to update. I am providing the codes below for both my gridview and the cs behind and would be grateful if someone could take a look, I assume it's a sort of minor sql issue on my part.

code

protected void UpdateButton_Click(object sender, EventArgs e) { originalDataTable = (DataTable)ViewState["originalValuesDataTable"]; foreach (GridViewRow r in GridView_ABC.Rows) if (IsRowModified(r)) { GridView_ABC.UpdateRow(r.RowIndex, false); } // Rebind the Grid to repopulate the original values table. tableCopied = false; GridView_ABC.DataBind(); }

View 4 Replies

Way To Make Database Field A DateTime Field To String

Oct 5, 2010

Dim query as String = "Select * from openquery (devbook, 'SELECT wb.arrival_time FROM web_bookings wb ')"All I need is to convert my arrival_time into a datetime field in the query

View 1 Replies

Data Controls :: How To Make Bound Field And Template Field Read-Only In Edit Item Template Of GridView

Jul 31, 2013

i am implementing a update query module.i am displaying all fields from a table for a term searched. well now i am implementing update option for the record which are displayed, i have like 70 columns in my table, and i want to know how to restrict some selected fields to be only read only while the form can be updated ?Like if user select to update a record then some selected field such as "Timestamp, UID etc some selected fields" remains READ ONLY !

View 1 Replies

AJAX ::possible To Make An DIV "editable"?

Jan 21, 2010

i several DIV's where the user should be able to insert html content via an editor.I want to enable the user to "click" inside the div and then it should be converted into an "Editor" (e.g.
http://cutesoft.net/asp/EnableAll.asp).

1. The Site opens

2. The editable areas are marked with an different background color

3. The user should click in this area

4. the area turns into an editor and a save button

5. on click the save button the content should be saved and the DIV content refreshed is this possible with AJAX and for what should i look for?

View 5 Replies

How To Show Plain Text In Password Field And Then Make It Regular Password Field On Focus

Jan 2, 2010

how to show plain text in password field and then make it regular password field on focus

View 3 Replies

State Management :: Hidden Field Value In User Control / Make The Hidden Field Save Its Value?

Mar 23, 2011

I have a custom user control which contains a asp hiddenfield object. The value of this hidden field is being set using javascript and I have verified that the value is being set properly. When a postback occurs the new value is not being saved and I cannot access it in my code.

I believe the problem is because the user control is not saved in viewstate and therefore the hidden field value is not saved accross postback. How can I make the hidden field save its value? I tried accessing it from the early page cycles and still no luck.

View 4 Replies







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