Ho dichiarato un array di 4 pulsanti:
Poi ho un datagrid dove ad ogni riga ho 4 pulsanti dichiarati così:codice:private string[] idBottoni = new string[4]{"b1","b2","b3","b4"};
Nell'itemDataBound associo ad ognuno dei 4 bottoni command name e argumentcodice:asp:button runat="server" Text="+" ID="b1"></asp:button>
Nel ItemCommand faccio il response.write del command argumentcodice: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"; } } } }
il problema è che in fase di visualizzazone nel response.write non appare il command argument, come se fosse nullo.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()); } }

Rispondi quotando