Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / August 2003

Tip: Looking for answers? Try searching our database.

Problem with edit

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jonas Karlsson - 27 Aug 2003 12:17 GMT
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
Jonas Karlsson - 27 Aug 2003 17:09 GMT
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);

> 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
[quoted text clipped - 43 lines]
>
> /Jonas Karlsson

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.