944,008 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 5852
  • ASP.NET RSS
Dec 20th, 2008
0

e.Item.DataItem=null in Repeater ItemCommand

Expand Post »
Hi.....

I am binding a Repeater control with List<int> at OnLoad event
ASP.NET Syntax (Toggle Plain Text)
  1. protected override void OnLoad(EventArgs e)
  2. {
  3. if(!Page.IsPostBack)
  4. {
  5. List<int> datasource =Get();
  6. if(datasource!=null)
  7. {
  8. rpt.DataSource=datasource;
  9. rpt.DataBind();
  10. }
  11. }
  12.  
  13. base.OnLoad(e);
  14. }
it works fine.....my Repeater bind successfully......i have a button at each Repeater Item....When i click on that button my Repeater Item Command is fire ......but my code e.Item.DataItem is null

protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
{
                if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
                {
                    if (e.CommandName == "Remove")
                    {
int i=(int)e.Item.DataItem // This Line shows error (my ItemDataBound event is working fine.....)
                        
                     }
                }
}
Last edited by peter_budo; Dec 21st, 2008 at 4:59 am. Reason: Keep It Organized - For easy readability, always wrap programming code within posts in [code] (code blocks) and [icode] (inline code) tags.
Reputation Points: 10
Solved Threads: 2
Light Poster
btech_Saurabh is offline Offline
39 posts
since Jan 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: the beer house web starter kit - msdtc
Next Thread in ASP.NET Forum Timeline: Referencing Detailsview template field





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC