Problem with edit

J

Jonas Karlsson

I have a edit problem with my DataGrid. The Update and Cancel buttons won't
show when I press Edit. What can be wrong?! The cod is to be included in a
Sharepoint WebPart therefor I'm not using any ordinary <asp:datagrid> tags.
The control is rendered using MyDataGrid.RenderControl()

I also have a problem with the EditCommand event. When building my control
after setting my event handler i get this error:

Method 'Northwind.CustomerRowProvider.DataGrid1_EditCommand(object,
System.Web.UI.WebControls.DataGridCommandEventArgs)' does not match delegate
'void System.EventHandler(object, System.EventArgs)'


My code:

SqlConnection myConnection = new SqlConnection("Integrated
Security=SSPI;Persist Security Info=False;Initial Catalog=TimeReport;Data
Source=(local);");
myConnection.Open();
SqlDataAdapter myCommand = new SqlDataAdapter("select * from Customer",
myConnection);
DataSet ds = new DataSet();
myCommand.Fill(ds, "Customer");
MyDataGrid = new DataGrid();
MyDataGrid.AutoGenerateColumns = false;
MyDataGrid.DataSource=ds.Tables["Customer"].DefaultView;
MyDataGrid.EditCommand += new
System.EventHandler(this.DataGrid1_EditCommand);



EditCommandColumn c = new EditCommandColumn();
c.EditText = "Edit";
c.UpdateText ="Update";
c.CancelText = "Cancel";
c.HeaderText = "";
MyDataGrid.Columns.Add(c);

MyDataGrid.DataBind();

myConnection.Close();



private void DataGrid1_EditCommand(object source, DataGridCommandEventArgs
e)
{
MyDataGrid.EditItemIndex = e.Item.ItemIndex;
MyDataGrid.DataBind();
}



/Jonas Karlsson
 
J

Jonas Karlsson

I solved this problem myself, but I am surprised that I couldn't find the
answer here...

The trick is to use
GridDays.EditCommand += new DataGridCommandEventHandler(GridDays_Edit);
 

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

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top