How set panel Default Button that is inside a details view in asp.net?

Posted by Avinash on Stack Overflow See other posts from Stack Overflow or by Avinash
Published on 2009-03-31T06:19:09Z Indexed on 2010/05/31 2:22 UTC
Read the original article Hit count: 380

<asp:panel ID="Panel1"  runat="server">

<asp:DetailsView ID="DetailsView1"

....

<asp:templatefield ShowHeader="False">

<insertitemtemplate>

<asp:Button ID="btnAdd" runat="server" CausesValidation="True" CommandName="Insert" Text="Insert"></asp:Button>

...
<asp:DetailsView>
</asp:panel>

and i write the code for setting the panels default button in details view's DataBound event

Button btnAdd = new Button();
  btnAdd = DetailsView1.Rows[indexNumber].FindControl("btnAdd") as Button;
  Panel1.DefaultButton = btnAdd.UniqueID;

but I get the error :
The DefaultButton of 'Panel1' must be the ID of a 
control of type IButtonControl.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about detailsview