Visualizzazione dei risultati da 1 a 2 su 2
  1. #1
    Utente di HTML.it L'avatar di Sonikag
    Registrato dal
    Mar 2004
    Messaggi
    2,080

    problema nel leggere CommandName e CommandArgument

    Ho dichiarato un array di 4 pulsanti:
    codice:
    private string[] idBottoni = new string[4]{"b1","b2","b3","b4"};
    Poi ho un datagrid dove ad ogni riga ho 4 pulsanti dichiarati così:
    codice:
    asp:button runat="server" Text="+" ID="b1"></asp:button>
    Nell'itemDataBound associo ad ognuno dei 4 bottoni command name e argument
    codice:
    		private void RepEventi_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) 
    		{ 
    			if(e.Item.ItemType == ListItemType.Item | e.Item.ItemType == ListItemType.AlternatingItem) 
    			{ 
    				foreach(string s in idBottoni) 
    				{ 
    					Button bottone = e.Item.FindControl(s) as Button; 
    					if(bottone != null) 
    					{ 
    						bottone.CommandArgument = "pippo"; 
    						bottone.CommandName = "pluto";
    					} 
    				} 
    			} 
    		}
    Nel ItemCommand faccio il response.write del command argument
    codice:
    		public void RepEventi_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) 
    		{ 
    			if(!(e.CommandArgument.ToString() == null))
    			{
    							Response.Write("il command argument è: " + e.CommandArgument.ToString()); 
    							}
    }
    il problema è che in fase di visualizzazone nel response.write non appare il command argument, come se fosse nullo.

  2. #2
    Utente di HTML.it L'avatar di Sonikag
    Registrato dal
    Mar 2004
    Messaggi
    2,080
    up

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 © 2026 vBulletin Solutions, Inc. All rights reserved.