Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Datagrid Control > Problem with edit

Reply
Thread Tools

Problem with edit

 
 
Jonas Karlsson
Guest
Posts: n/a
 
      08-27-2003
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





 
Reply With Quote
 
 
 
 
Jonas Karlsson
Guest
Posts: n/a
 
      08-27-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
GridView edit validation, edit dropdown list, delete popup confirm =?Utf-8?B?a2Vu?= ASP .Net 1 01-23-2006 12:51 PM
Snapshot restraint - edit, edit, edit Alan Browne Digital Photography 24 05-10-2005 10:15 PM
Snapshot restraint - edit, edit, edit Patrick Digital Photography 0 05-06-2005 10:53 PM
Edit All Function for DataGrid, and Moving the Edit Function in a DataGrid Schultz ASP .Net 3 02-14-2005 04:47 AM
copying value of DDL in a Datagrid "pre-edit command" to value in "post edit command" San Diego Guy ASP .Net 0 08-07-2003 08:59 PM



Advertisments