473,320 Members | 2,029 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problems with Dropdownlist in EditMode in nested gridview

Hi all.
I have a field in a gridview as templatefield which is a label in view mode
and a dropdownlist in edit mode with his datasource.
This gridview is inserted as templatefield in another mother gridview.

GRIDVIEW1
[key field] - [gridview2]

GRIDVIEW2
[templatefiled] [other fields]

TEMPLATEFIELD
- edit mode - dropdownlist
- view mode - label

In the evetn GRIDVIEW2_rowUpdating i need to assign key and value of
dropdownlist to my memory datatable fileds.
This is the code

protected void GridView2_RowUpdating(object sender, GridViewUpdateEventArgs
e)
{
GridView GridView2 = (GridView)sender;
GridViewRow currRow = GridView2.Rows[e.RowIndex];
GridView2.EditIndex = e.RowIndex;
Label grnLabel = (Label)GridView2.Parent.FindControl("Codice_giorno ");
string grnId = grnLabel.Text; //cella del parametro grn_id
Ds_Rapporto.Tables["Attivita"].DefaultView.RowFilter = "ATT_GRN='" + grnId
+ "'";
DataRow currDr =
((DataView)GridView2.DataSource)[Convert.ToInt32(e.RowIndex)].Row;
DropDownList listaCommesse = (DropDownList)currRow.FindControl("Commessa");
currDr["ATT_COMMESSA_ID"] = Convert.ToInt32(listaCommesse.SelectedValue);
currDr["ATT_COMMESSA"] = listaCommesse.SelectedItem.Text;
....
}

THE ERROR IS THIS
"System.InvalidCastException was unhandled by user code
Message="Unable to cast object of type 'System.Web.UI.WebControls.Label'
to type 'System.Web.UI.WebControls.DropDownList'."

The problem is that the application consider the label instead of the
dropdownlist?
Anyone can explain me how can i refer to the dropdownlist?
Thanks
Fabrizio
Nov 6 '07 #1
0 1850

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: tfsmag | last post by:
I have a Grid that I've set up to have two of the fields use dropdownlists while in edit mode. Now I can bind the data to the dropdownlists just fine. My problem is that the second dropdown depends...
1
by: Giovanni | last post by:
Dear Friends/Gurus, I have exhausted myself and have yet no solution to the following: I have an ASP.NET 2.0 Survey type application. On a page, I have placed a GridView which is bound to an...
4
by: J055 | last post by:
Hi I thought I was trying to do something very simple but I'm have a lot of trouble trying to do the following. <asp:FormView ID="fvGroups" runat="server" DataKeyNames="GroupID"...
0
by: sgtmarcjones | last post by:
How do I access a dropdownlist that is nested within a Formview ItemTemplate Gridview Template? I want to see a label (lgbTimeKeep ! TextValue of ddlName dropdownlist) instead of a dropdownlist...
1
by: Laurahn | last post by:
Hi: How can i display tooltip message on a dropdownlist template control inside a GridView Footer. I found this code working well, but it dosen't work inside a gridview: </head> <body>...
0
by: Fabrizio | last post by:
Hi. I have two nested gridviews. The detail GV in the EditTemplate has one dropdownlist. On rowupdating of the detail GV i have to assign to my dataset fields the key and the value selected in...
0
by: minhtran | last post by:
Hi everyone I have a problem when I want to edit the value from nested dropdownlist in Gridview, Please, anyone can help me to solve this problem, a great appreciation from me in advance. here is...
6
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I have a gridview control with a template column that has a textbox and when the control is bound to the datasource the textbox is filled ok. I then change what is in the textbox in the gridview...
0
by: Dan | last post by:
Hi, I have a detailsview with two fields: in editmode, one is a textbox and the other is a dropdownlist. i want to update both fields using the detailsview. My problem: when clicking on the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.