.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to make a cell editable in gridview?

Posted By:      Posted Date: October 07, 2010    Points: 0   Category :WPF

I was trying to create a gridview which should allow to edit a perticular cell on clicking on it. But is not working as expected. Here is my code. Can anyone tell whats the issue with this.

<Window x:Class="Window1"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:sys="clr-namespace:System;assembly=mscorlib"
    Title="Window1" Height="279" Width="672">

        <Style x:Key="TextBoxStyle" TargetType="{x:Type TextBox}" >
            <Setter Property="Background" Value="#00ffffff" />
            <Setter Property="BorderBrush" Value="#00ffffff" />
            <Setter Property="Acce

View Complete Post

More Related Resource Links

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

Editable multiple nested gridview


Greetings everyone,

I've got this page where I display a 3 level nested gridview. First gridview displays data, 2nd one displays data based on the 1st one's row and 3rd one displays data based on the 2nd gridview. All of this works perfectly, including the edit mode for the 3rd gridview. 

The issue comes when I make each gridview collapsible, again, it works fine but when I click on "Edit" on the 3rd gridview all the grids collapse, I can then re-open them and the "edit mode" is still present and I can still save my updated data. But that collapsing thing is quite annoying.

I based a lot of my code from this page: http://www.codeproject.com/KB/webforms/EditNestedGridView.aspx

And I understand how I can fix my issue on a 2 level nested gridview, by simply adding the C# code:

protected void GridView2_RowEditing(object sender, GridViewEditEventArgs e)
            GridView gvTemp = (GridView)sender;
            gvUniqueID = gvTemp.UniqueID;
            gvEditIndex = e.NewEditIndex;

This makes allows me to save the index and prevent it from collapsing when I'm editing. Unfortunately, because I'm actually editing the 3rd gridview, if I code:

How To Access Datakeys In Javascript...and How To make gridview Column Visible true in javascript


How To Access Gridview's Datakeys In Javascript...and How To make gridview Column Visible true in javascript

Reply me..

How can i add a textbox into a GridView Cell dynamically and how can i retrieve entred data

Hey, i think that the the subject can explain what i need, it's about adding a TextBox control with the code behind into a GridView, and also about how can i retrieve entered data after submitting, im using C#,Thanks.

I need to set the value of a gridview cell during update.

Hi,  I've been reading the posts here and I'm not finding, or maybe just not understanding, the answer I need so here's my problem. I have a small gridview and the update works very well. The issue is I need to have one of the fields set to a value from my code either when the record is open for undating or when the update runs.  Here is my gridview and the datasource info:<asp:GridView ID="GridViewItemLog" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" CellPadding="3" DataKeyNames="LogID" DataSourceID="SqlDataSourceItemLogEntries" GridLines="Vertical" onrowdatabound="GridViewItemLog_RowDataBound" onrowupdating="GridViewItemLog_RowUpdating" onrowediting="GridViewItemLog_RowEditing"><AlternatingRowStyle BackColor="Gainsboro" /><Columns><asp:CommandField ButtonType="Image" CancelImageUrl="~/Resources/StopSmall.png" EditImageUrl="~/Resources/EditSmall.png" ShowEditButton="True" UpdateImageUrl="~/Resources/Save.png" /><asp:Boun

How to make a DataGridView Cell/Column not enterable / selecatble

Hi, I am trying to make a Column in a DataGridView non-entaerable (the user should not be able to set focus to the cell neither using the mouse nor the keyboard). I already tried to change the CurrentCell property in the CellStateChanged. But in this event-handler the CurrenCell is the "old" one; setting it to any value doesn't help, because the value is set after calling this procedure. In Delphi there is an event-handler for entering a cell, where you can tell whether the user is allowed to enter a cell. Is there anything comparable in C#? Any other suggestions?

How to make a connection between a word in the cell (href)? and a rule of the same or another table

 HelloHow to make a connection between a word in the cell (href)? and a rule of the same or another table with sql. Is there also finished editors?

ASP.NET GridView help!! Need to be able to scroll an individual cell up and down.

Hi everyone.  I have an ASP.NET GridView displaying the below grid.  As you can see, the column on the right has a LOT of text and it stretches the column.  I need to be able to set a fixed width for JUST that column (maybe like 200px) and have vertical scroll bars on that cell so the user could scroll down to read the rest of the text, is that possible to do?Here's my markup: <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource2" AutoGenerateColumns="False" AllowPaging="True" AlternatingRowStyle-Wrap="False" CellPadding="4" ForeColor="#333333" GridLines="None"> <RowStyle Height="30px" BackColor="#EFF3FB" /> <Columns> <asp:BoundField DataField="Customer_Name" HeaderText="Customer" SortExpression="Customer" /> <asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" /> <asp:BoundField DataField="Module" HeaderText

make onle specific cells in gridview as hyperlink

Dear all,   i have gridview and im displaying the employement history of employee. and im providing a hyperlink in empid to open employee page with update mode ..so that user can update the record. i have an issue here.only if the employeeresigned = "N" empid should be hyperlink, if its "Y" it should not be a hyperlink. How to do this.  <asp:TemplateField HeaderText="empid" SortExpression="empid">   <ItemTemplate> <asp:LinkButton ID="LinkButton1" runat="server" OnCommand ="empDetails_disp" Text='<%# Eval("empid") %>' CommandArgument='<%# Eval("empid", "{0}") %>' ForeColor="#0000C0"></asp:LinkButton> </ItemTemplate> </asp:TemplateField> am wondering how to do this 1) shall i replace all the linkbutton with label if the resignedstatus = "Y" - how to do this? 2) or shall i make the empid as boundfields instead of templatefields and write code on rowbound...with checkin that if resigned = "Y" then e.Row.Cells(0).BackColor = Drawing.Color.blue  e.Row.Cells(0).Attributes.Add("onclick", "empDetails_disp")  e.Row.Cells(0).Attributes.Add("class", "statusclass") ...... in this case i can use only javascript fu

How to make Bookmark for gridview rows

Dears, I have a gridview in my page with some rows, and users are navigated to this page from another page which pass a querystring to this page. I want to scroll the page to the appropriate row upon recieved querystring in page_load() method of the page. How can I do this ?!

How to make cause validation false for Show Edit buttons in Gridview control

  HI. I am having 2 (dept name, City)dropdownlist, 1 Save button once if we click the save then record will be displayed in grid (Gridview with ShowEditbutton =true and I have Edit logic in my page). But if I click on Edit button then if I try to update the value then it is firing a message "Select dept" because dept dropdown present in the page so I want to make cause validation false for Show Edit buttons (update and cancel). Pleaase tell me Thanks

problem in make editable a combobox in datagridview in c#

how do i make my datagridview combobox aditable for the user while i has a drop down list. in this case sometimes user needs to edit the selected item from the list.how can i implement this?

Javascript code to copy specific cell of gridview row

Dears, I need a javascript code to copy the text content of a cell of a row in gridview. I have a button in each row that users click it and the text content a cell of that row should be copied in a textbox out of gridview

Editable Spreasheet-like Gridview

I need to display 144 records in some form of Grid/Spreadsheet view.  Currently I have the records being  displayed in a Gridview, however this means that if the user needs to make multiple changes to the data that is being displayed then they would have to hit the edit and then update for each row.  What I would like to be able to do is have them Edit whatever rows and columns they need to and then have them click update once. Is this possible, if yes then how?   Any assistance would be greatly welcomed.

WpfDataGrid make cell background fill entire cell

Hi!  I'm setting DataGridColumn.CellStyle to a background color and to a horizontal alignment. If I do not set the horizontal alignment the whole cell is filled with the background color but if i set the horizontal alignment the background color only is shown behind the text in the cell. I've seen some workarounds to this problem (http://stackoverflow.com/questions/1379902/setting-column-background-in-wpf-listview-gridview, setting the Margins on the DataGrid and the Cell margin) but it does not work for me. The background is still only shown behind the text   private void ApplyCellStyle(Style defaultColumnStyle, DataGridColumn dataGridColumn, Color backgroundColor, HorizontalAlignment horizontalAlignment) { var style = new Style(typeof(DataGridCell), defaultColumnStyle); var backgroundPropertySetter = new Setter { Property = Control.BackgroundProperty, Value = new SolidColorBrush(backgroundColor) }; var horizontalAlignmentPropertySetter = new Setter { Property = FrameworkElement.HorizontalAlignmentProperty, Value = horizontalAlignment }; style.Setters.Add(horizontalAlignmentPropertySetter); style.Setters.Add(backgroundPropertySetter); dataGridColumn.CellStyle = style; }   Does anyone know a solution to this problem?    Regards, Lina

Gridview Cell Hightlight with toggling

Hi, I have a dynamically generated Gridview wherein every tablecell within the gridview is assigned a particular class(background color) at run time. Each cell has  a linkbutton and I have a onClientClick event where, I would like to highlight the container cell when the user clicks on the linkbutton.If the user clicks it back, I would it to  get back its original class/background color that it was bound with earlier. I am trying to implement this in Javascript by passing the original className but I am unable to toggle the color back to original.Please help. Here is a snippet of code. I could do it in c# but I would like to implement this in Javascript as it won't  cause postback.Thanks so much!//Linkbutton databinding event private void lb_DataBinding(Object sender, EventArgs e)     { private void lb_DataBinding(Object sender, EventArgs e)    { LinkButton l = (LinkButton)sender; l.OnClientClick = String.Format("doClick({0},{1},'{2}','{3}','{4}','{5}','{6}'); return false;", x, y, className, tbPercentSoldUpfrontSelected.ClientID, tbPercentChangeDemandSelected.ClientID, tc.ClientID, l.ClientID);} function doClick(val1, val2, val3, control1, control2, control3, control4)         {         &nbs
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend