Problem in OnItemDataBound

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?
 
S

Sam

What do you mean by "why does it change all the previous records"? Did you
mean that all previous records become null/empty or blank space?

Sam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,049
Latest member
Allen00Reed

Latest Threads

Top