.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

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

Posted By:      Posted Date: August 31, 2010    Points: 0   Category :ASP.Net
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  

View Complete Post

More Related Resource Links

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

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. 

Populate textbox in FormView Control in Edit Mode with querystring

Can someone please tell me what I am doing wrong here. I am simply trying to get a querystring value and pass it to a textbox in a formview with the default view set to edit mode.     Protected Sub fv_Detach_Engine_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles fv_Detach_Engine.DataBound        If fv_Detach_Engine.CurrentMode = FormViewMode.Edit Then            Dim tbx_IDProfileAccount As TextBox = TryCast(fv_Detach_Engine.FindControl("tbx_IDProfileAccount"), TextBox)            If tbx_IDProfileAccount Is Nothing Then                tbx_IDProfileAccount.Text = Request.QueryString("IDProfileAccount")            End If        End If    End Sub  

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

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

Populate dropdownlist in Edit mode programatically


I'm trying to programatically populate some dropdownlists inside a formview in EDIT mode, like this below.

 Dim FVM As String = FormViewMemberProfile.CurrentMode.ToString

        If FVM = "Edit" Then

            Dim ddlDays As DropDownList = CType(FormViewMemberProfile.FindControl("ddlDays"), DropDownList)
            Dim ddlYears As DropDownList = CType(FormViewMemberProfile.FindControl("ddlYears"), DropDownList)

            Dim i As Integer = 1

            For i = 1 To 31

            Dim k As Integer

            For k = 1930 To 2008

        End If

I orginally had this running as part of the pagelaod event, but I'm thinking that b/c the page loads first, it doesn't populate the fields in EDIT mode until after the data is saved, and then page is reloaded. Now it knows it's in "Edit" mode. Am I thinking clearly here? Not sure if this is the order of things... Anyhow...

So I thought I should just use a formview_modechanged (or similar event) so when the user switches modes, it populates the fields - but I'm not sure which event I should use. I've tried "Modechanging", "modechanged", "prer

How to get gridview control row values


I have a gridview with a dropdownlist (ddlGrade) in one column and a textbox (txtText) and checkbox(cbxCheck) in another.

When the checkbox is checked I to fire an event that will use the data from other controls in that row.

In the method can get the checkbox value using:

public void onCheckedChanged_CheckedInfo(object sender, EventArgs e)

           Checkbox cbxChecked = (Checkbox)sender;


My question is... how do I get the value of the other two controls that are in the same row (dropdownlist and the textbox) at the same time? But not the values from any other rows?

Thanks, Travis

Accessing gridview cell values


Hi All,

In my application Iam using GridView, in this there are fields (Quantity, Price, Amount) the user can enter Quantity Field value which is a template field (textbox). Iam calculating Amount(Quantity * Price) using Javascript and assigning to the Amount Column cells as below

Gridviewcell.innerText=Quanity * price.

and when user clicks on the Save button I want to add these details of Gridview to the database.

when I try to access the values of the gridview using below code

For i=0 to GridView.rows.count-1

GridView.Rows(i).Cells(2).toString ( for Example)

Next i

It is not displaying the changed value instead it is displaying the default value before calculating the amount.

Before implementing the Javascript part, I had done this in the code behind and it was working fine... Now I just dont want the page to get load so I used javascript.

Can any one help me out in able to access the value of Gridview cells which are assigned using Javascript.



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


 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

Accessing the selected value of a dropdownlist control in a Form View


I need to verify the selection in a dropdown list control is not a certain value.  It is in the edit mode of a formview.

just to verify that I could access it I tried to put the value in a label,  however it is always empty:


this is what I used

  'Dim droplist5 As DropDownList = DirectCast(FormView1.Row.FindControl("DropDownList5"), DropDownList)


            LabelHeaderwarning.Text = droplist5.SelectedValue.ToString


I also tried the validation controls but they don't seem to work with a drop down control.


Any suggestions on this would be extremely helpful



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"  >

Setting Task Field Values in Custom .aspx Edit Form and accessing through ExtendedProperties


Since we're using WSS 3.0 and not MOSS 2007, we have to create and use ASP forms for any custom Workflow Task Edit pages instead of being able to use InfoPath forms (which would be nice...maybe some day we'll step up to MOSS). The custom Workflow Edit Pages are used for custom Task Content Types that we create so that our Workflow Tasks can have additional fields beyond the standard Workflow Task fields. Once you've collected the values for the Task fields from the user on the ASP Workflow Task Edit form, the typical procedure is to create a hashtable and fill the hashtable with key/value pairs that represent the names of your Task fields and their associated values, as such:

// This function is called when the user clicks the Save/Submit button
// on the Custom Task Edit ASP form
public void btnSubmit_Click(object sender, EventArgs e)
  // Create a hashtable that will be used to update the values of task fields
  Hashtable taskHash = new Hashtable();
  // For each field, create two values in the hashtable. If the field name 
  // matches a field in the Task content type, the field name will not be 
  // searchable as a key within the ExtendedProperties hashtable. So 
  // create a second field that is a duplicate of the first but having a 
  // name that doesn't exactly match an existing field in the Task 
  // content type. That way it will be a searchable ke

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=&#

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;


Inplace Edit in GridView

In this article I am presenting a different way to look at EditItemTemplate, using which user navigation for editing is reduced and . it looks very different (see screeen shots) then regular implementation of GridView.
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