Y
yme
Hi guys,
I have a datagrid with 4 columns, in the 2nd column I have a Label and
in the 4th a DropDown.
As I want to change the content of the DropDown according with the
content of the label I've built a function that executes on
ItemDataBound:
protected void dgCriteriosDB(object sender, DataGridItemEventArgs e){
//identification for the criteria
int idCriterio = 0;
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==
ListItemType.AlternatingItem))
{
Label lbl_idCriterio =
(Label)e.Item.FindControl("lbl_idCriterio");
Label lblCriterio = (Label)e.Item.FindControl("lbl_criterio");
idCriterio = System.Convert.ToInt32(lbl_idCriterio.Text);
//change the select statement
src_subCriteriosAval.SelectCommand="SELECT [id_subcriterio],
[id_criterio], [desc_sub_criterio], [imp_relativa], [ordem] FROM
[MSP_PMO_Scoring_SubCriteriosAvaliacao] WHERE ([id_criterio]
="+idCriterio+")";
/apply the select statement
DropDownList dg3 =
(DropDownList)e.Item.FindControl("drpSubCriterios");
dg3.DataSourceID = "src_subCriteriosAval";
dg3.DataTextField = "desc_sub_criterio";
dg3.DataValueField ="imp_relativa";
dg3.DataBind();
}
}
The function seems to be woorking well but if it fires for each row,
why does it change all the previous records?
I have a datagrid with 4 columns, in the 2nd column I have a Label and
in the 4th a DropDown.
As I want to change the content of the DropDown according with the
content of the label I've built a function that executes on
ItemDataBound:
protected void dgCriteriosDB(object sender, DataGridItemEventArgs e){
//identification for the criteria
int idCriterio = 0;
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType ==
ListItemType.AlternatingItem))
{
Label lbl_idCriterio =
(Label)e.Item.FindControl("lbl_idCriterio");
Label lblCriterio = (Label)e.Item.FindControl("lbl_criterio");
idCriterio = System.Convert.ToInt32(lbl_idCriterio.Text);
//change the select statement
src_subCriteriosAval.SelectCommand="SELECT [id_subcriterio],
[id_criterio], [desc_sub_criterio], [imp_relativa], [ordem] FROM
[MSP_PMO_Scoring_SubCriteriosAvaliacao] WHERE ([id_criterio]
="+idCriterio+")";
/apply the select statement
DropDownList dg3 =
(DropDownList)e.Item.FindControl("drpSubCriterios");
dg3.DataSourceID = "src_subCriteriosAval";
dg3.DataTextField = "desc_sub_criterio";
dg3.DataValueField ="imp_relativa";
dg3.DataBind();
}
}
The function seems to be woorking well but if it fires for each row,
why does it change all the previous records?