MVC :: How To Use SelectionList In An Editable Table
Feb 17, 2010
I have an editable html table where all rows are editable at the same time.
One column contains a dropdownlist to select an employee. I want to pass the dropdownlist's items from the controller to the view.
My View iterates through the list and displays a dropdownlist for the employee.
[Code]....
Do I have to pass a separate SelectList for each row or is it possible to share the SelectionList?
How do I set the selected value using Html.DropDownListFor() when sharing the same SelectList?
View 2 Replies
Similar Messages:
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
Jun 16, 2010
I have a mobile selection list (see blow) that I had programmatically filled in from a generic collection of Status object (see below) which was retrieved from the database since I wanted to use the ID and Value stored in there to the selection list.
Mobile SelectionList Sample
[Code]....
Status Object model
[Code]....
Filled in a generic collection of Status object
[Code]....
Then, I tried to fill in the mobile selection list control using:
[Code]....
Now, when I tried to get the value of the selection list... it is giving me the same value as to what was stored in the text of the selection list. I tried using the following snippet:
[Code]....
or
[Code]....
Is there anyway I can get the value of the selection list that was retrieved from the database instead of the indexes?
View 7 Replies
Jul 20, 2010
I have a very strange issue where SelectionList always returns NULL when i try check its Selected Item/Value. I Googled a bit and I found out that when i click the submit button, the page is being refreshed and the SelectionList is being data bound again so it will revert back to its original behavior.
Then i tried enclosing the binding code in the Page_Load event in a !IsPostBack but still when i try to access the Selected property it is null and an exception is thrown.
My code goes something like this... (the braces are not matched properly)
static SelectionList[] Symptoms;
static string UserID = "";
cmbSymptoms1,cmbSymptoms2,cmbSymptoms3 and cmbSymptoms4 are SelectionLists. I took them in to an array of SelectionList and then set the properties.
I had to make them static or else when i click the button to update, they will not retain their values.
protected void Page_Load(object sender, EventArgs e)
{
if (this.IsPostBack == false)
{
//System.Diagnostics.Debug.WriteLine("Not IsPostBack");
if (Request.QueryString["id"] != null && Request.QueryString.ToString() != "")
{
//System.Diagnostics.Debug.WriteLine("id query string is not null :- " + Request.QueryString["id"]);
myclass = new Class1();...........
View 1 Replies
Nov 9, 2010
i am working in MVC & want to show data in asp:gridview & also want that on mouse click on any row that row becomes editable.
View 9 Replies
Mar 2, 2010
I am developing my app in asp.net web forms. The textbox is set like this
<asp:TextBox ID="txt1" runat="server" Enabled="false" ></asp:TextBox>
and this is the corresponding HTML markup
<input name="txt1" type="text" value="1.0" id="txt1" disabled="disabled" />
It is not editable upto this point.
I enable Caret browsing in IE8 (press F7) and then this field becomes editable, though the text is grayed out and consequently gives a wrong feeling to the user that the field is editable. This does not happen if I mark the textbox as readonly, but I do not want to mark it as a readonly field. how to have the textbox in disabled mode when in Caret Browsing.
Edit1: I am not looking for a solution which would change IE settings/registry, am looking for a programmatic solution as my site is a public facing website
Edit2: View states are enabled for the page and for the controls
View 2 Replies
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
Aug 9, 2010
I have directly call to mspaint.exe on button click but doesn.t open it is shows on task manager but not show on broser
View 1 Replies
Mar 15, 2010
I need to save the marks in database for each student...I have one drop down list..In this drop down contain 2 std 3 std 4 std, etc..if the user click 2 std ,2 std subjects are display in the grid with textbox for marks upload...If the user click 3 std, 3 std subjects are display in the grid with textbox...and also save the entered marks into database..and i need to edit the marks.
View 1 Replies
Sep 21, 2010
Is there any sample shows the best way to create an editable grid with textboxes, so when user clicks on the save button, the entire grid's textboxes are posted back to controller and bind to its model? I prefer not using any 3rd party grid such the one comes with MvcContrib.
View 2 Replies
Nov 11, 2010
can you send the link where does i get the editable jquery grid for asp.net mvc2.
View 1 Replies
Apr 15, 2010
I've seening quite a few posts on here regarding grids, but nothing specifically asking for a free grid component that supports editing. Has any body come across such a thing? Is there a JQuery pluggin that I could use? If not has anybody got any pointers on a good approach to writing my own (using asp.net mvc2 and/or jquery)?
View 1 Replies
Oct 25, 2010
a customer asked me for a web app, written in ASPNET, that can use an editable grid (that works with a SqlServer DB) in the similar manner as Excel works; i can use gridView with Edit link in every row but i wanted to know if there are better solutions (possibly free..) that i can use.
View 1 Replies
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
Jan 18, 2010
Getting all the rows of Gridview to be editable mode.
Here is Gridview Source..
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ods"
DataKeyNames="abc" EmptyDataText="There is no entry..." AllowPaging="false">
<Columns>
<asp:TemplateField>
[Code]....
like I have 10 rows in gridview, I want to show all the rows in editable mode.
View 3 Replies
Apr 1, 2010
problem is I have a table with rows and columns. I would like to update each row independently without the entire table gets updated. Basic problem is UpdatePanel can only be applied to column level rater than row level. If I add updatepanel with in each column with updatemode as conditional, then the event associated to the drop down list was not able to update controls outside the column like enabling another dropdown box outside updatepanel within same row and add items to it.
View 2 Replies
Feb 14, 2013
I am currently working on a new data application that is a vb.net web based application using visual studio. I have a form with a datagrid view that I have customized to have all rows editable at all times. I need to get this form to show a blank row for inserting data if there is no data returned from the sql server table. I also need to get this form to prompt you to save your changes when you navigate away from the screen by any method. My asp and vb.net code is shown below.
Code:
<%@ Page Title="frmPublication" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="frmPublication.aspx.vb" Inherits="MCRN.frmPublication" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
[Code] .....
View 4 Replies
Sep 6, 2013
I have hard coded more than 100 values in dropdown, I want to create dropdown in editable formate suppose I entered any character and search the list related entered char in dropdown,but in asp.net dropdown not editable.
View 1 Replies
Apr 12, 2012
I take a data grid for display item in data grid I can edit and update and this is work fine but I do not want that my HolidayID column will not be editable ...
<Columns><asp:BoundColumn DataField=HolidayID HeaderText="HolidayID" >
<ItemStyle BackColor=GhostWhite />
</asp:BoundColumn> </Columns>
View 1 Replies
Dec 15, 2010
I have a problem similar to the one found in this Question I have a ListView nested inside of another listview. The outer Listview is bound to an object in the codebehind.
listViewOuter.DataSource = myObject[0].someProperty;
listViewOuter.DataBind();
Where someProperty is a List of another object(mySecondObject). The inner Listview needs to be editable and it is bound in the markup to another property(secondObjectProperty) of type List in the mySecondObject as such:
DataSource='<%# Eval("secondObjectProperty")%>'
This works fine to display the data, however I cannot figure out how to put the nested listview into edit mode. I am handling the OnItemEditing command and setting the EditIndex to the proper row however the mode of the nested LV never changes. I have tried every imaginable combination of updates panels and rebinding both the inner and outer listviews however nothing seems to work
heres the LV markup(psuedocode)
<updatePanel>
<asp:ListView ID="outerListView" runat="server">
<layouttemplate here>
<itemTemplate>
<aspListView ID="innerListView" DataSource="<%# Eval("secondObjectPropery")% onitemEditng="editMethod">
</asp:LsitView>
</itemTEmplate>
</asp:ListView>
</updatePanel
View 2 Replies
Nov 9, 2010
I'm creating a gridview that should always have a row on the top of the gridview irrespective of whether there exists data to bind to or not. This row should have a column with a textbox to insert data.I tried creating a header template and setting showheader to true,but it won't display.
<asp:GridView ID="gvwMessages" runat="server" AutoGenerateColumns="false" ShowHeader="true"> <Columns>
<asp:TemplateField HeaderText="FileNote">
<ItemTemplate>
<asp:CheckBox ID="CheckBox2" runat="server" />
</ItemTemplate>
<HeaderTemplate>
<asp:CheckBox ID="CheckBox3" runat="server" />
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Date">
<ItemTemplate>
<asp:Label ID="Label7" runat="server" Text="Label"></asp:Label>
</ItemTemplate>
<HeaderTemplate>
<asp:Label ID="Label8" runat="server" Text="Label"></asp:Label>
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Created By">
<ItemTemplate> <asp:Label ID="Label9" runat="server" Text="Label"></asp:Label> </ItemTemplate>
<HeaderTemplate>
<asp:Label ID="Label10" runat="server" Text="Label"></asp:Label>
</HeaderTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Message Lines">
<ItemTemplate> <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine" Enabled="false"></asp:TextBox> </ItemTemplate>
<HeaderTemplate>
<asp:TextBox ID="txtHeaderMessage" runat="server" TextMode="MultiLine"></asp:TextBox> </HeaderTemplate> </asp:TemplateField>
</Columns>
</asp:GridView>
</p>
View 10 Replies
Jun 3, 2010
I have a simple app I am messing around with its a basic Master/Details layout. The details panel is actually a tab panel and on one of the tab panels it has a GridView. Within that grid view it shows the "current" in database information with all cells as read only. I then have an add button that inserts a row into the GriView and allows the user to enter some information. The first item in my GridView is a DropDownList, which is populated from an ObjectDataSource. This drop down is basically my unique index and there can only be one selected value per GridView.
What is the best way to remove the values from the list that are already in the GridView? Do I just need to remove the data source and add a OnDataBinding method that iterates through the grid view and generates a valid list of values? I can't use a service method because if the user adds two rows they would have the option to insert duplicates description types.
View 1 Replies
Aug 7, 2011
I am in need of a very simple grid which the user should be able to edit very quickly. The grid will display a list of food items (name and price) that make up a menu.
My usual approach here is just a GridView bound to a collection of the food items with an Edit button to the left of every row. When the Edit button is clicked I navigate to an Edit page where the user can edit that item and click OK to save it to the database and then go back to the grid page, where the grid is reloaded and shows the edited item.
This approach however is much to slow, the user should be able to edit the grid much more quickly, ideally without posting back (either fully, partially or via ajax).
What I'm thinking is really simple, but I don't have the necessary javascript skill to create this...:
A UserControl that simply creates a new row of TextBoxes for every food item (along with maybe a Delete button). The 'grid' is thus always in 'edit mode' (it always shows the textboxes in every row) and the user can type in any textbox to change the name or price. When this change is made, nothing happens server side, yet. When the user presses Save, I finally run a save method that just checks all rows and saves the new values to the database.
Since the grid is so simple (just Name and Price and the underlying data has a unique Id as well obviously) I think this should be possible, but I wouldn't know how to create this...
I did try, I had a UserControl 'MenuGrid' that was nothing but a PlaceHolder (and two labels for the 'Name' and 'Price' menu headers). It has a DataSource property that I set to a collection of food items in the menu, and then for each of those food items I add a MenuGridRow (another UserControl) to the Placeholder. This MenuGridRow contains two TextBoxes and the Delete button. It also contains a HiddenField control that gets the Id of the food item.
Loading works fine, I can get all the data in this 'grid', but I don't see any way to save it back. Once I changed the items and want to Save on the server, I don't see any way to access the MenuGridRows from the MenuGrid (let alone accessing the TextBoxes on that in turn). I think the problem is that it's all just rendered to html and during runtime there is no such thing as a MenuGrid or MenuGridRow anymore. So all I have is a couple of TextBoxes with seemingly random names and there's no way for me to determine which Textbox belongs to which HiddenField (which contains the Id).
Also, I don't see any way to handle the deleting of a row; I was thinking to just run some javascript that deletes the MenuGridRow from the MenuGrid, but again same problem, there's no such thing as a MenuGridRow at that point and I'd have to figure out which TextBoxes and HiddenField belong to that row and then delete them via javascript.
I tried looking for an editable ajax enabled grid as well, so I don't have to do it all by myself, but I didn't really find anything useful. Most of the grids I found don't even work properly, some work but are still very slow (there's still a postback, they just put the grid in an UpdatePanel but that doesn't make it any faster).
View 1 Replies
Nov 6, 2010
I have a RadGrid which has a column like:
<telerik:GridTemplateColumn HeaderText="Car" >
<ItemTemplate>
<asp:Label ID="MakeLabel" runat="Server" Text='<%# Eval("Make") %> />
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="MakeTextBox" runat="Server" Text='<%# Bind("Make") %> />
</EditItemTemplate>
</telerik:GridTemplateColumn >
and I'm wanting to set it up so that this column will allow input when inserting new values but won't when updating values.
View 2 Replies
Feb 25, 2011
How we will find the curson position(top,left) in a contenteditable div using Jquery or javascript.
View 3 Replies