Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Custom control : getting Rowcount 0 on button event of the control.

Custom control : getting Rowcount 0 on button event of the control.

Scheduled Pinned Locked Moved ASP.NET
wpfwcfhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    Imran Khan Pathan
    wrote on last edited by
    #1

    I am working on custom control. I am creating databound control. I have one property name RowDataSource that accept DataRowCollection as data source and I bind control on OnDataBinding event. I have another property name RowItem. My code looks like this.

    public DataRowCollection RowDataSource
    {
    get
    {
    if (ViewState["rowDataSource"] == null)
    {
    ViewState["rowDataSource"] = null;
    }
    return (DataRowCollection)ViewState["rowDataSource"];
    }
    set
    {
    if (value == null)
    {
    throw new ArgumentException("unvalid data source.", this.ID);
    }
    ViewState["rowDataSource"] = value;
    }
    }
    public RowCollections ExelRows
    {
    get
    {
    // rCollection is object of RowCollections class
    if (rCollection == null)
    {
    rCollection = new RowCollections();
    }
    return rCollection;

    }
    }

    OnDataBinding event code
    protected override void OnDataBinding(EventArgs e)
    {
    base.OnDataBinding(e);
    if (RowDataSource != null)
    {
    foreach (DataRow dr in RowDataSource)
    {
    //RowItem is my class
    RowItem item = new RowItem();
    item.Text = dr[rTitle].ToString();
    this.ExelRows.Add(item);
    }
    }
    }

    CreateChildControls method to render control
    protected override void CreateChildControls()
    {
    if (ExelRows.Count > 0)
    {
    //here i am rendering table structure to add exelrows and create control.
    }
    }

    Now, I am binding this control with DataRowCollection and It works file. I have one button in this control and I am raising bubble event when button is clicked. My problem is that when I click on button then CreateChildControls method is called first before OnDataBinding event. so I am getting ExelRows.Count = 0. so what I have to do to getting all rows on every bubble event of control. Thanks Imrankhan

    please don't forget to vote on the post that helped you.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups