no, nel Page Load non c'è nulla.. la prima volta che carico la pagina il repeater rimane vuoto.. e non databindato.. ne faccio il databind solo dopo aver premuto il pulsante con il codice che ho scritto (quello dove c'è il ciclo che non và bene).. cmq ecco il codice completo della classe:
codice:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class admin_Default : System.Web.UI.Page
{
protected DataTable dtRighe;
protected DataRow drRighe;
protected DataSet dsRighe;
int rowNumber;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnAddRow_Click(object sender, EventArgs e)
{
rowNumber = 0;
if (Session["cachedArchive"] == null)
{
dtRighe = new DataTable("Review");
dtRighe.Columns.Add("clid");
dtRighe.Columns.Add("clmod");
dtRighe.Columns.Add("clprzpubb");
dtRighe.Columns.Add("climpriv");
}
else
{
dtRighe = (DataTable)Session["cachedArchive"];
}
if (dtRighe.Rows.Count > 0)
{
rowNumber = dtRighe.Rows.Count;
}
drRighe = dtRighe.NewRow();
drRighe[0] = rowNumber;
drRighe[1] = txtmod.Text.ToString();
drRighe[2] = txtprzpubb.Text.ToString();
drRighe[3] = txtimprival.Text.ToString();
dtRighe.Rows.Add(drRighe);
Session["cachedArchive"] = dtRighe;
repViewRow.DataSource = (DataTable)Session["cachedArchive"];
repViewRow.DataMember = "Review";
repViewRow.DataBind();
}
protected void repViewRow_ItemCommand(object source, RepeaterCommandEventArgs e)
{
int a = Convert.ToInt32(e.CommandArgument);
Response.Write(a.ToString());
}
protected void repViewRow_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
((Button)e.Item.FindControl("btnDelRow")).CommandArgument = rowNumber.ToString();
}
}
}
ed ecco il codice della pagina.. solo il repeater ovviamente (l'html mi sembra aquanto superfluo postarlo
)
codice:
<asp:Repeater ID="repViewRow" runat="server" OnItemCommand="repViewRow_ItemCommand" OnItemDataBound="repViewRow_ItemDataBound">
<ItemTemplate>
<tr>
<td style="width: 111px">
<%#DataBinder.Eval(Container.DataItem,"clid") %>
</td>
<td style="width: 53px">
<%#DataBinder.Eval(Container.DataItem,"clmod") %>
</td>
<td style="width: 159px">
<%#DataBinder.Eval(Container.DataItem,"clprzpubb") %>
</td>
<td>
<%#DataBinder.Eval(Container.DataItem,"climpriv") %>
</td>
<td style="width: 123px">
<asp:Button ID="btnDelRow" runat="server" Text="-" Width="25px" /></td>
</tr>
</ItemTemplate>
</asp:Repeater>