470,641 Members | 1,463 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,641 developers. It's quick & easy.

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.

[key field] - [gridview2]

[templatefiled] [other fields]

- 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
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 =
DropDownList listaCommesse = (DropDownList)currRow.FindControl("Commessa");
currDr["ATT_COMMESSA_ID"] = Convert.ToInt32(listaCommesse.SelectedValue);
currDr["ATT_COMMESSA"] = listaCommesse.SelectedItem.Text;

"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
Anyone can explain me how can i refer to the dropdownlist?
Nov 6 '07 #1
0 1775

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by tfsmag | last post: by
1 post views Thread by Giovanni | last post: by
1 post views Thread by Laurahn | last post: by
reply views Thread by Fabrizio | last post: by
6 posts views Thread by =?Utf-8?B?UGF1bA==?= | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.