Visualizzazione dei risultati da 1 a 4 su 4
  1. #1
    Utente di HTML.it L'avatar di TigerWB
    Registrato dal
    Apr 2002
    Messaggi
    286

    problema con Item_Command

    ciao a tutti ho un problemino in c# con l’ Item_Command ,
    ho scritto questa funzione
    public void Item_Command(Object sender, DataGridCommandEventArgs e)
    {
    if (e.CommandName == "elimina")
    {
    DataRow dataRiga = getDataRow(DataGridForums.DataKeys[e.Item.ItemIndex].ToString());
    dataRiga.Delete();
    string strSql = "Delete From TabPost Where idPost=" + DataGridForums.DataKeys[e.Item.ItemIndex].ToString();
    objUtente.ExInsertCommand(strSql);
    }
    }

    che mi dovrebbe intercettare il CommandName per poi eliminare il record appropriato.
    ho inserito anche nella funzione che mi crea visual studio
    private void InitializeComponent()
    {
    this.DataGridForums.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Item_Command); this.DataGridForums.ItemDataBound += new System.Web.UI.WebControls.DataGridItemEventHandler (this.Item_Bound);
    this.DataGridForums.SelectedIndexChanged += new System.EventHandler(this.DataGridForums_SelectedIn dexChanged);
    this.Load += new System.EventHandler(this.Page_Load);

    }
    this.DataGridForums.ItemCommand += new System.Web.UI.WebControls.DataGridCommandEventHand ler(this.Item_Command);

    che mi dovrebbe intercettare l’evento come ho fatto con il itemDataBound che mi funziona ma con il ItemCommand non funziona, ho anche inserito nel datagrid l’evento OnItemCommand con il nome dell’funzione Item_Command ma niente,
    qualcuna mi saprebbe dire come faccio a intercettare questo evetnto in c#?
    grazie

  2. #2
    Prova con

    this.DataGrid1.ItemCommand += new System.EventHandler(this.Item_Command)

    Fammi sapere
    Ciao
    K
    Kalman

  3. #3
    Utente di HTML.it L'avatar di TigerWB
    Registrato dal
    Apr 2002
    Messaggi
    286
    Originariamente inviato da Kalman
    Prova con

    this.DataGrid1.ItemCommand += new System.EventHandler(this.Item_Command)

    Fammi sapere
    Ciao
    K

    ho provato con this.DataGridForums.ItemCommand += new System.EventHandler, ma non mi intercetta l'evento ItemCommand
    come faccio, nessuno ha mai utilizzato questo evento?
    spero che qualcuno mi aiuti

  4. #4
    Guarda nell'esempio di questa pagina di --> MSDN


    Ciao
    K
    Kalman

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.