find control inside datalist on page load

himalldi

New Member
\[quote\] \[quote\] I want to find an item in the datalist on page load method this is my code \[/quote\]\[/quote\]\[code\]protected void Page_Load(object sender, EventArgs e) {\[/code\]\[quote\] \[quote\] some code here \[/quote\]\[/quote\]\[code\] for (int i = 0; i < count ; i++) { LinkButton LinkButton6 = (LinkButton)sender; DataListItem item = (DataListItem)LinkButton6.NamingContainer; LinkButton lnkbtn6 = (LinkButton)DataList1.Items[item.ItemIndex].FindControl("LinkButton6"); } \[/code\]\[quote\] \[quote\] ,but this error appears to me :Unable to cast object of type 'ASP.default2_aspx' to type 'System.Web.UI.WebControls.LinkButton'. \[/quote\]\[/quote\]
 
Back
Top