e.Item.DataItem=null in Repeater ItemCommand

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Jan 2008
Posts: 39
Reputation: btech_Saurabh is an unknown quantity at this point 
Solved Threads: 2
btech_Saurabh's Avatar
btech_Saurabh btech_Saurabh is offline Offline
Light Poster

e.Item.DataItem=null in Repeater ItemCommand

 
0
  #1
Dec 20th, 2008
Hi.....

I am binding a Repeater control with List<int> at OnLoad event
  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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC