F
Fabrizio
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
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