datagrid not visible when databind() on editcommand

G

Guest

j9 (Programmer) Feb 15, 2005
I have a datagrid with an arraylist as the datasource. I added an Edit,
Update, Cancel button column and coded the EditCommand event handler. When I
click on the Edit button, the datagrid disappears. Have I lost my datasource
during postbacks or something? Here's my code:

private void Page_Load(object sender, System.EventArgs e)
{
if(!Page.IsPostBack)
{
PopulateForm();
}
}

private void PopulateForm()
{
dgReferences.DataSource = mySOP.Refs;//(mySOP.Refs is an arraylist)
dgReferences.DataKeyField = "RefID";
dgReferences.DataBind();
}

private void dgReferences_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgReferences.EditItemIndex = e.Item.ItemIndex;
dgReferences.DataBind();
}
 
E

Elton Wang

It should be

private void dgReferences_EditCommand(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
dgReferences.EditItemIndex = e.Item.ItemIndex;
PopulateForm();
}

HTH,

Elton Wang
(e-mail address removed)
 

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

No members online now.

Forum statistics

Threads
473,989
Messages
2,570,207
Members
46,782
Latest member
ThomasGex

Latest Threads

Top