I test the demo on link: http://csharpdotnetfreak.blogspot.com/2009/05/gridview-sqldatasource-insert-edit.html It worked fine. But when I get data from a function in code behind, instead of use DataSourceID="SqlDataSource1" like demo, by bind data to gridview in code behind like that:
protected void Page_Load(object sender, EventArgs e)
{
lblMessage.Text = "";
if (!IsPostBack)
{
GridView1.DataSource = MyFunctionGetData();
GridView1.DataBind();
}
}
When I click to Edit link in gridview, it don't change to Update and Cancel link and don't run to EditItemTemplate in debug mode like above demo.