use Event Handling

Discussion in 'ASP .Net Web Controls' started by Angelo, Jun 30, 2003.

  1. Angelo

    Angelo Guest

    Hi,
    I'm using a WebUserControl which build a table . In that table , there r
    some LinkButton Controls which handle an event . For the fitst time my
    program run properly , but for the second , systm show me this error . "
    An error has occurred because a control with auto-generated id
    'WebUserControl11:_ctl2' could not be located to raise a postback event. To
    avoid this error, explicitly set the ID property of controls that raise
    postback events. "

    the make it more clear , i pase some parts of my code here .

    private void CreateLables()

    {

    int intDivide;

    try

    {

    //Create Counter LinkButton Lables

    intDivide=Convert.ToInt32(MainSize)/3;

    intDivide=intDivide+1;

    LinkButton[] ocConters;

    Table LastTable=new Table();

    ocConters=new LinkButton[intDivide];

    TableCell[] ocTableCell=new TableCell[intDivide];

    TableRow ocTableRow =new TableRow();

    for (int intNum=0;intNum<intDivide;++intNum)

    {

    ocConters[intNum]=new LinkButton();

    ocConters[intNum].Click += new
    System.EventHandler(this.LinkButton_Click);


    ocConters[intNum].Text=Convert.ToString(intNum+1);

    ocTableCell[intNum]=new TableCell();


    ocTableCell[intNum].Controls.Add(ocConters[intNum]);


    ocTableRow.Cells.Add(ocTableCell[intNum]);

    }

    LastTable.Rows.Add(ocTableRow);

    this.Controls.Add(LastTable);


    }

    catch (Exception ocException)

    {

    throw (ocException);

    }

    }







    /// <summary>

    ///

    /// </summary>

    /// <param name="sender"></param>

    /// <param name="e"></param>

    private void LinkButton_Click(object sender, System.EventArgs e)

    {

    this.Controls.Clear();

    try

    {

    Products ocProducts=new Products();

    for (int intNum=0;intNum<intDivide;intNum++)

    {

    if (
    sender.Equals(ocConters[intNum]))

    {


    ocProductData=ocProducts.FillForm(intNum,false);


    MakeProductTable(ocProductData,2);

    }

    }

    }

    catch (Exception oc)

    {

    Response.Write(oc.ToString());

    }



    }


    What should i do . plzzzzzzzzz HELP :(

    Regard
    Angelo
     
    Angelo, Jun 30, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sunil

    Pager and Event Handling

    sunil, Jul 18, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    390
    sunil
    Jul 18, 2003
  2. LilC
    Replies:
    1
    Views:
    2,954
    Otis Mukinfus
    Apr 30, 2006
  3. Mark Tarver
    Replies:
    22
    Views:
    1,336
    J Kenneth King
    Apr 26, 2009
  4. Peter
    Replies:
    34
    Views:
    1,973
    James Kanze
    Oct 17, 2009
  5. Iñaki Baz Castillo
    Replies:
    1
    Views:
    200
    Iñaki Baz Castillo
    Apr 15, 2008
Loading...

Share This Page