Repeater in not easy like gridview.
in .aspx file :
Item command Event :
protected void rptStudent_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "msg", "alert('Delete Command');", true);
}
else if (e.CommandName == "Edit")
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "msg", "alert('Edit Command');", true);
}
}
Item Databound Event :
protected void rptStudent_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Response.Write(((Label)(e.Item.FindControl("lblID"))).Text);
}
}
}
in .aspx file :
Edit | Delete | Company Name | Legal Name | Owner Name | Address1 | Address2 | Address3 |
---|---|---|---|---|---|---|---|
ImageUrl="~/images/edit.png" runat="server" /> | <%# DataBinder.Eval(Container, "DataItem.Company_Name")%> | <%# DataBinder.Eval(Container, "DataItem.Legal_Name") %> | <%# DataBinder.Eval(Container, "DataItem.Owner_Name")%> | <%# DataBinder.Eval(Container, "DataItem.Address1")%> | <%# DataBinder.Eval(Container, "DataItem.Address2")%> | <%# DataBinder.Eval(Container, "DataItem.Address3")%> |
Item command Event :
protected void rptStudent_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "msg", "alert('Delete Command');", true);
}
else if (e.CommandName == "Edit")
{
Page.ClientScript.RegisterStartupScript(Page.GetType(), "msg", "alert('Edit Command');", true);
}
}
Item Databound Event :
protected void rptStudent_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Response.Write(((Label)(e.Item.FindControl("lblID"))).Text);
}
}
}
No comments:
Post a Comment