Question

Je sais que la question est un peu saccadé et peut-être trompeur, mais j'ai un gridview avec DropDownLists sur les lignes. J'ai créé un AddHandler et un délégué pour la SelectedIndexChanged et il arrive à la sous. Voici le code pour que:

AddHandler ddlmgr.SelectedIndexChanged, AddressOf ddlmgr_SelectedIndexChanged
Public Delegate Sub DropDownList_SelectedIndexChanged(ByVal sender As Object, ByVal e As DropDownList_SelectedIndexChanged)

Protected Sub ddlmgr_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)


End Sub

Comment puis-je obtenir si GridView_RowCommand n'est pas appelé Id de la ligne?

Était-ce utile?

La solution

Great work Fonctionne très bien pour moi absolument

DropDownList ddl = (DropDownList)sender;
Control p = ddl.Parent;
//you are going to loop because the immediate
//parent may not be the repeater item but instead a 
//container control of some kind (say a template)
while (p.GetType() != typeof(RepeaterItem))
{     
  p = p.Parent;     
  if (p == null) 
      return; //we have reached the top of the control tree
}
RepeaterItem ri = (RepeaterItem)p;
int index = ri.ItemIndexreturn index;

Autres conseils

Vous devez faire un peu de travail sur le terrain que je ne peux pas fournir 100% des détails sans écrire le code et le tester sur mon propre ici, que je suis incapable de le faire à l'heure actuelle, mais le code devrait aller dans ce sens .

dans le ddlmgr_SelectedIndexChaged,

  1. Lancez votre expéditeur à un DropDownList
  2. accès la propriété de la partie dropdownlist.
  3. Vérifiez Augmentin est un GridItem (ou RepeaterItem ou tout autre, vous voyez l'idée)
  4. Si oui, obtenir les éléments itemIndex. Si l'accès non sa propriété parent.
  5. Continuer jusqu'à ce que vous trouverez votre objet Row.

Espérons que cela aide. Sinon, peut-être quelqu'un avec un peu plus d'accès libéral peut carillon

DropDownList ddl = (DropDownList)sender;
Control p = ddl.Parent;

//you are going to loop because the immediate 
//parent may not be the repeater item but instead a 
//container control of some kind (say a template)
while (p.GetType() != typeof(RepeaterItem))
{
     p = p.Parent;
     if (p == null) return; //we have reached the top of the control tree
}
RepeaterItem ri = (RepeaterItem)p;
int index = ri.ItemIndex
return index;

DropDownList ddltxt = (DropDownList) expéditeur;         chaîne temp2 = ddltxt.SelectedItem.Text;         chaîne temp3 = ddltxt.SelectedItem.Value;         temp chaîne = ddltxt.ID.ToString ();         int strlength = temp.Length;         chaîne strLastchar = temp.Substring (strlength - 1, 1);         int intlastchar = int.Parse (strLastchar.ToString ());         chaîne commonpart = temp.Substring (0, strlength - 1);

    if (intlastchar == 1)
    {
        string targetdropdownid = commonpart + "2";
        DropDownList targetlist = (DropDownList)TableRow11.FindControl(targetdropdownid);
        using (conn = new SqlConnection(ConnectionString))
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top