View Full Version : Newbie: WebMatrix, ASP.NET 1.1 & C#

Apr 12th, 2006, 06:23 PM
Hey, basically I've created a new ASP.NET page using C# with WebMatrix and added a database with one table called Items. I've dragged the table onto my page to create a MxDataGrid and I've added the fields I want to display - now I want to be able to edit or delete the individual rows displayed in my Data Grid and stored in my database. As you can see from my code I've got an EditCommandField for Edit/Update/Cancel and a ButtonField for Delete. I've been searching on google for several hours but any examples I find are either written in Visual Basic or use Visual Web Developer+ASP.NET 2.0 and take advantage of Grid View. I'm very new to this so sorry if I've said/asked anything out of place. Here's my code so far:

<wmx:MxDataGrid id="DataGrid2" runat="server" DataSourceControlID="AccessDataSourceControl1" BorderColor="#CCCCCC" AllowSorting="True" DataMember="Items" BackColor="White" CellPadding="3" DataKeyField="ItemID" BorderWidth="1px" BorderStyle="None" AutoGenerateFields="False">
<SelectedItemStyle font-bold="True" forecolor="White" backcolor="#669999"></SelectedItemStyle>
<ItemStyle forecolor="#000066"></ItemStyle>
<FooterStyle forecolor="#000066" backcolor="White"></FooterStyle>
<HeaderStyle font-bold="True" forecolor="White" backcolor="#006699"></HeaderStyle>
<PagerStyle horizontalalign="Center" forecolor="#000066" backcolor="White" mode="NumericPages"></PagerStyle>
<wmx:EditCommandField ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></wmx:EditCommandField>
<wmx:ButtonField Text="Delete"></wmx:ButtonField>
<wmx:BoundField Visible="False" DataField="ItemID" ReadOnly="True" HeaderText="ID"></wmx:BoundField>
<wmx:BoundField DataField="ItemName" SortExpression="ItemName" HeaderText="Name Of Item"></wmx:BoundField>
<wmx:BoundField DataField="ItemPrice" SortExpression="ItemPrice" HeaderText="Price ()"></wmx:BoundField>
<wmx:BoundField DataField="ItemInStock" SortExpression="ItemInStock" HeaderText="Amount In Stock"></wmx:BoundField>
<wmx:BoundField DataField="CategoryName" SortExpression="CategoryName" HeaderText="Category"></wmx:BoundField>

Any help would be much appreciated. I do realise that I need an Update statement and a Delete statement which is called when I click either link button and that I need a databind() method but again I'm not sure.