use Event Handling

A

Angelo

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top