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);
"Jonas Karlsson" <> wrote in message
news:...
> 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_EditComma nd(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
>
>
>
>
>
|