473,837 Members | 1,656 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_rowUp dating i need to assign key and value of
dropdownlist to my memory datatable fileds.
This is the code

protected void GridView2_RowUp dating(object sender, GridViewUpdateE ventArgs
e)
{
GridView GridView2 = (GridView)sende r;
GridViewRow currRow = GridView2.Rows[e.RowIndex];
GridView2.EditI ndex = e.RowIndex;
Label grnLabel = (Label)GridView 2.Parent.FindCo ntrol("Codice_g iorno");
string grnId = grnLabel.Text; //cella del parametro grn_id
Ds_Rapporto.Tab les["Attivita"].DefaultView.Ro wFilter = "ATT_GRN='" + grnId
+ "'";
DataRow currDr =
((DataView)Grid View2.DataSourc e)[Convert.ToInt32 (e.RowIndex)].Row;
DropDownList listaCommesse = (DropDownList)c urrRow.FindCont rol("Commessa") ;
currDr["ATT_COMMESSA_I D"] = Convert.ToInt32 (listaCommesse. SelectedValue);
currDr["ATT_COMMES SA"] = listaCommesse.S electedItem.Tex t;
....
}

THE ERROR IS THIS
"System.Invalid CastException was unhandled by user code
Message="Unable to cast object of type 'System.Web.UI. WebControls.Lab el'
to type 'System.Web.UI. WebControls.Dro pDownList'."

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 1894

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

Similar topics

6
7077
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 on the first dropdown to pass a parameter to it. If I have a selectedvalue set to the second drop down, when i select a new value from the first drop down it gives me this error. "Databinding methods such as Eval(), XPath(), and Bind() can...
1
3255
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 SQLDataSource. The GridView contains 3 columns: QuestionNumber, QuestionText, and a TemplateField. Each row in the GridView represents a question in a table (Ex.: "18. Satisfaction Level").
4
12918
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" DataSourceID="odsGroups" DefaultMode="Insert" Visible="false" OnItemCommand="fvGroups_ItemCommand"> <InsertItemTemplate> <asp:DropDownList ID="ddlEditMode" runat="server"
0
5965
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 in the FormView ItemTemplate Nested Gridview ddlName ItemTemplate. My label is named lgvTimeKeep and the dropdownlist name is ddlName. Thanks!
1
5244
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> <div id="tooltip"></div>
0
961
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 the DDL. I'm not able to cast in the rowupdate the dropdownlist (return always null) How can i do? Thanks Fabrizio
0
1555
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 my sample code ASP.NET with VB.NET Protected Sub gridview5_rowdatabound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView5.RowDataBound Dim Columns() As String Dim myDataset As New...
6
1993
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 control and in the gridview_RowDataBound event I have string DiscDescrip = Convert.ToString((e.Row.Cells.FindControl("txbxDiscgv") as TextBox ).Text); This returns what was initially loaded in the textbox but not what I had just changed it...
0
1481
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 edit button, the modified text in the textbox is effectively updated in the table, but instead of updating the chosen value of the dropdownlist, the field in the table becomes empty (old value is updated by nothing). The items of the dropdownlist...
0
9846
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
10886
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10580
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10634
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7007
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5674
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4052
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3126
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.