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

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

changing Asp.net Gridview's cell from Label to edit mode in code behined file

Posted By:      Posted Date: October 05, 2010    Points: 0   Category :ASP.Net

 Hi all,

In my asp.net application i'm using gridview to which i'm binding data dynamically by writing a select query in code behined file (all column's are autogenerated) now i want to change gridview cell to edit mode from label to textbox or dropdown on clicking of gridview's cell.How can i achive this in code behined file.

thanks in advance

View Complete Post

More Related Resource Links

Want to cancel edit mode of gridview in the code.


I have several places where I have a gridview and dataview set, and when I hit an edit button on the gridview it opens up the dataview.  

When I hit a cancel button fom the dataview I have this code that returns mew to the gridview:

        dvwUser.Visible = false;
        gvwUserList.Enabled = true;
        gvwUserList.Visible = true;


        dvwUser.Visible = false;


Moved from WinXP to Win7 - don't see choice to open file in read only or edit mode


I just recently moved from Win XP Pro SP3 to Win 7 32-bit Pro. I am logging into domain X normally. Our Sharepoint 2007 server authenticates only on domain Y. So I start Internet Explorer with "run as different user" and provide my domain Y credentials. All fine. 

In win XP, after I did this, when I click on an Excel file on Sharepoint, I would get a dialog asking if I wanted to check out and edit or open as read only. 

In win7, I don't get that choice. The file simply opens, and I get a bar at the top which allows me to check out the file if I wanted to. 

How can I restore the functionality I used to have, with the dialog for checking out the file before opening it?

Edit MSI file dynamically using c# code. : very urgent


Hi All,

I had created one application and this is multi client application means code is same but setup is different for each client with diff. client Code in app config file, diff product code, upgrade code, setup name, display name.

So i am looking for a way to edit my MSI file dynamically and made changes into that for each client using code or any other way dynamically.

Do any one has idea how to do this Dynamically/Anyother.

Thanks in advance.


Accessing a row's dropdownlist values AFTER the gridview control is in Edit mode

Hello, I have a gridview control. When it goes into Edit mode, there are 3 dropdownlists in one cell that are populated by separate stored procedures during the RowDataBound event. The 1st dropdownlist's value is used as a parameter to determine what the 2nd dropdownlist is populated with. The 2nd dropdownlist's value is used as a parameter to determine what the 3rd dropdownlist is populated with. Everything works fine when the row is first put into Edit mode. While I'm in Edit mode and I change the selection in the 1st dropdownlist, how do I access the control so I can feed this new parameter to the 2nd dropdownlist? I have the first 2 dropdownlists set for AutoPostBack so that the Page_Load event is fired when the user changes a value. I know how to get access to these controls via the FindControl method when the row is being databound but how do I find the control during the Page_Load event? Thanks for any help!!!   Penny  

Gridview edit mode - What event does enter key call?

I have sort of a very specific problem.  I have a gridview with a few different template columns and a commandfield with the standard "edit" link.  There is no sqldatasource associated with it at all.  In the code, I pull some data from an sql database into a datatable and set the gridview's datasource to be the datatable.This all works fine.  When I hit the "edit" button, the standard textbox shows up where it needs to so that I can edit the data.  The problem is the updating portion.  I have programatically removed the "update" button and left the "cancel" button for design reasons. I want the user to be able to hit "enter" in order to update the data in the data table.  Then, when they're ready, they can click a submit button which will extract the data from the datatable and update the database.I'm having trouble with this 'enter key' business.  When you edit the data and hit "enter" while in edit mode, the page posts back, and the previous values are placed in the gridview.  What event was just  called?  I need a way to take what the user put in and place it in my datatable.  What are my options?Thank you. 

Have templatefield in edit mode and datasource defined in code behind

Is this possible? Some sample code:<asp:GridView ID="gvConcerns" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"> <RowStyle BackColor="#EFF3FB" /> <Columns> <asp:TemplateField HeaderText="Number" Visible="true" SortExpression="Number"> <EditItemTemplate> <asp:Label ID="lblEditNo" runat="server" Text='<%# Eval("number") %>'></asp:Label> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Part" Visible="true" SortExpression="part"> <EditItemTemplate> <asp:Label ID="lblEditPart" runat="server" Text='<%# Eval("part") %>'></asp:Label> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="List" Visib

DetailsView error "must be in edit mode to update a record" when I have set edit mode in code behind

Hi,I have a DetailsView within an UpdatePanel.  I programmatically put the DetailsView into edit mode, change the fields then call the UpdateItem method which causes the "must be in edit mode to update a record" exception.  Am I missing something blindingly obvious? <asp:UpdatePanel ID="upSpecificShout" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true" > <ContentTemplate> <asp:DetailsView ID="dvSingleShout" DataSourceID="sdsSingleShout" runat="server" AutoGenerateRows="false" OnDataBound="SetDVIcons" HeaderStyle-CssClass="noDisplay" DefaultMode="ReadOnly" AutoGenerateEditButton="true" OnItemCommand="dvItemCommand"> <fields> <asp:TemplateField ShowHeader="false"> <ItemTemplate> <asp:Panel ID="dlSpecificDetailsViewPanel" runat="server" CssClass="i_am_a_shout"> <h2><asp:LinkButton ID="lblShoutTitle" runat="server" Text='<%# Bind("Shout_Title") %>' On

Put outer-gridview in non-Edit mode when user edits inner-Gridview

using vb.net/asp.net 2005.(sorry last post I had the grids reversed, what I meant to say is this:I have an outer gridview I'll called "Outer" and an inner-gridview inside that I'll call "inner".There are times when the user will put Outer into edit mode and then put Inner into edit mode and change a value in Inner.  The user is not supposed to be able to do that.So when the user wants to edit Inner I need to change the edit mode of Outer so that Outer is Not editable.   EX: I want to do something like this but not sure in which event of outer to do it:'event fired when user puts inner gridview into edit mode Protected Sub Inner_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles Inner.RowEditing 'put outer gridview into non-edit mode Outer.EditIndex = -1 End Sub Does anyone know how to do this, is this the right event?  Also I assume I have to rebind the gridview?thanks,MC

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

Code behind file changing


I have a code behind file which has only a few placeholders and literal. The gridview control and others are added in real time according to program conditions. I noticed that once in a while th eprogram stopped working because the .aspx file is changed  and some of the place holders disappeared - Why? (the bolded lines disappeared once in a while)



<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DRProWebReport.aspx.cs" Inherits="DRProWeb.DRProWebReport" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

Can't retrieve value from gridview row in edit mode



I have a grid view. When I click edit, the OnRowCommand fires and the row goes into edit state. Label becomes a TextBox. I then attempt to alter this value in some way and click update. This again fires the OnRowCommand event. The problem is, when I attempt to capture the new value, it instead just shows the original value.

In my grid view I have:


<asp:TemplateField HeaderText="Start Name">





How to validate a GridView textbox in edit mode


I am working with VWD Express and Visual Basic. Please take this into consideration if you are willing to answer my question.

I do have the following code for a GridView.

        PageSize="100"  >

Edit all cells within a particular column => Gridview (vb code)


Hi there,

I'm looking for a technique to edit a whole column (vertical) instead of a row (horizontal).
Suppose i have 10 rows en 5 columns (like in Excel), and i want to edit all digits from different students (rows) for test number 3 (column).

How can i do that?

Can someone help me out here?



GridView RowDataBound and Edit mode


I have a gridview and a template column:

<asp:TemplateField HeaderText="Active">
                            <asp:CheckBox ID="chkbxActive" runat="server" Checked ='<%# Bind("Active") %>'  />
                            <asp:Label ID="lblActive" runat="server" Text='<%# Bind("Active") %>'></asp:Label>

Variable column name in GridView edit mode



I have implemented globalization in my website by using Global Resources. I thought of implementing it not only on controls but in database fields. So for some columns which would be single columns in normal conditions, I considered multiple columns for different culture. For example if there was a [Title] column, I replaced it with [Title-en-US], [Title-en-GB], [Title-es-ES] and etc.

I have a web page with a GridView control that displays the content of that table. In a normal case (without globalizing),  I would have a TemplateField in the GridView like this:

                        <asp:TemplateField HeaderText="Title" SortExpression="Title">
                                <asp:Label ID="Label1" runat="server" Text='<%# Bind("myTable.Title") %>'></asp:Label>
                                <asp:DropDownList ID="DropDownList1" runat="server" AppendDataBoundItems="true" DataSourceID="myDataSource"
                                    DataTextField="Title" DataValueField="XID" SelectedValue=&#

How do I run php code with an html file by changing the web.config file?


I have a windows server and would like to add php code to my .html files. I know this is possible with linux servers with .htaccess files but how do I do it with a windows server? I called my hosting provider and they said I need to forget about .htaccess and look into the web.config file. What I want is for my server to read html files and execute any php code it finds. I can't find the code I need to add to the web.config file.

I am quite new to all this.  I switched my server to a windows server with IIS 7 a few months ago. But I find asp.net way too difficult for this beginner. I can't switch back to a linux server since my business partner is creating pages with ASP.net

I just want to execute php code inside of html files.  Any help is greatly appreciated, thank you.

Unable to open xls file in edit mode.


XLS files that I have created in office 2007 and saved down to 2003 format cannot be opened in edit mode by some users who have office 2003.  Trying to open from Sharepoint site with server version 2007.  Versioning is on.  Check out is required.  They have the appropriate permissions as contributer.  Any ideas?  I had them run this thinking it would help, but no dice.  "Go To Start > Run > Type webfldrs.msi

Click on Select Reinstall Mode button (not Reinstall button)

Select all options

Click on OK

Now click on the Reinstall button

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