hi all,
i've got around the referencing the dropdownlist problem to some extent... the selected index property is available, so i enumerate my datatable comparing the primary keys and set the index appropriately.
now the pb is recovering the selected value by the user during an update in order to send it as a parameter to my Stored procedure....
i can mail my code, but it's a bit of a mess

________________________
class DDLTemplate : System.Web.UI.ITemplate {
string strParent;
DataView dataparent;
int RowToEdit;
public DDLTemplate(string strParentbinding, DataView dView, int rowEditing){
this.strParent = strParentbinding;
this.dataparent = dView;
this.RowToEdit = rowEditing;}
public void InstantiateIn (System.Web.UI.Control container){
DropDownList ddl = new DropDownList();
ddl.DataValueField="id"+ strParent;
ddl.DataTextField="lib"+ strParent;
ddl.DataSource = dataparent;
ddl.ID="ddlparent";//this ID is not implemented in run time
ddl.DataBinding += new System.EventHandler(this.BindDDL);
container.Controls.Add(ddl);
//depending on row neing edited, show the ddl or show the label

Label lbl = new Label();
lbl.ID="lblparent";
lbl.DataBinding += new System.EventHandler(this.BindLbl);
container.Controls.Add(lbl);}
private void BindDDL(object sender, System.EventArgs e){
DropDownList ddl = (DropDownList)sender;
DataGridItem container = (DataGridItem)ddl.NamingContainer;
//use itemindex property of container to know whether this line is in edition or read only...
//and hide or show control accordingly
if(container.DataSetIndex== this.RowToEdit) {
ddl.Visible=true;
ddl.SelectedIndex= GetDBindID(DataBinder.Eval(container.DataItem,GetDBinding("id").ToString()).ToString());}
else
//no binding!
ddl.Visible=false;}
private void BindLbl(object sender, System.EventArgs e){
Label lbl = (Label)sender;
DataGridItem container = (DataGridItem)lbl.NamingContainer;
//use itemindex property of container to know whether this line is in edition or read only...
//and hide or show control accordingly
if(container.DataSetIndex!= this.RowToEdit) {
lbl.Visible=true;
//bind data to ddl
lbl.Text=GetDBindLib(DataBinder.Eval(container.DataItem,GetDBinding("id").ToString()).ToString());}
else {
//no label binding!
lbl.Visible=false;}}
private string GetDBinding(string prefix) {
return prefix + strParent; }
private string GetDBindLib(string data){
IEnumerator Myenum = dataparent.GetEnumerator();
//need to enumerate data to find libellé for identifiant for each row...
while (Myenum.MoveNext()) {
DataRowView tmpRow = (DataRowView)Myenum.Current;
string sInt= tmpRow.Row[0].ToString();
string sLib = tmpRow.Row[1].ToString();
if (sInt == data) return sLib;
}
return "vide";
}
private int GetDBindID(string libellé){
int intindex = -1;
IEnumerator Myenum = dataparent.GetEnumerator();
//need to enumerate data to find libellé for identifiant for each row...
while (Myenum.MoveNext()) {
intindex+=1;
DataRowView tmpRow = (DataRowView)Myenum.Current;
string sInt= tmpRow.Row[0].ToString();
string str = tmpRow.Row[1].ToString();
if (sInt == libellé)return intindex;}
return intindex;
}
}
________________________
and the code calling the class:
_______
private void DoGridGestion(){
this.dgridGestion.Visible=true;
string element = Session["GererElement"].ToString() + "s";
switch (element){
case "Structures": //affichage directe datagrid avec ttes les structures
this.dgridGestion.DataSource = dsDatasetAntennes.Tables[element];
break;
default:
string ddlValue = this.ddlAppartenance.SelectedItem.Value;
/* passage au code pour prendre en compte choix du DDL pour eventuel filtrage avant d'afficher le contenu du datagrid*/
string parentID =recoverParentField(Session["GererElement"].ToString());
//apply filter to show only users choice members
DataView srcFiltered = new DataView(dsDatasetAntennes.Tables[element]); //view containing elements for the grid
if(ddlValue!= "-1") srcFiltered.RowFilter= "id" + parentID + " = '"+ ddlValue +"'";
//use of class begins here
//add template for ddl
TemplateColumn tc = new TemplateColumn();
tc.HeaderText = parentID;
switch(this.dgridGestion.EditItemIndex){
case -1: //mode lecture
tc.ItemTemplate = new labelTemplate(parentID, dsDatasetAntennes.Tables[parentID + "s"].DefaultView);
break;
default: //mode edition
tc.ItemTemplate = new DDLTemplate(parentID, dsDatasetAntennes.Tables[parentID + "s"].DefaultView, this.dgridGestion.EditItemIndex);
//dataview containing dependance/parent elements.
break;
}
this.dgridGestion.Columns.AddAt(3,tc);
this.dgridGestion.DataSource = srcFiltered;//apply filtered dataview as source for datagrid
break;
}
this.dgridGestion.DataBind();
}
_______
thx in advance....
david