I just created a base page with SqlDataSource, which does everything you want to do.
Here is what I did. Drag SqlDataSource from the toolbar to your page in design mode. Click Smart Tag and configure the data source. Click "New Connection". If you are working with a local installation of MySql, then most likely the server name is localhost, the username is root, and the password is all that you specified when installing and configuring the MySql server on your computer. Choose your database. It is always recommended that you click the "Test Connection" button here to make sure that it works. Now go through the remaining masters (Next, Next). When you go to the "Configure Selection" page, after you have specified which table you are requesting and which fields, make sure you click on the extended button on the right and click "Create Insert, Update and Delete." Now finish the wizard.
At this point you need to go to the original view. For me, the generated statements do not match the MySql syntax, so you must fix them. The easiest way is to do a search / replace in its original form and replace all β[β and β]β with β`). Keep in mind that this is not an apostrophe. This is another similar view (I donβt know what you call it) to the left of your 1 on the top line of your keyboard number, you will also need to add the actual field names after the "?" In the insert, update and delete operations for the parameters to work correctly.
So, go back to Design View, drag the GridView element onto your page, in the Smart Tag for GridView, select "Select a data source" and select the data source on your page that you just created (probably called SqlDataSource1 if you changed the name when its creation). Hit update the circuit. If it works, it can provide you with a confirmation window, but then it should update your GridView and show the columns in your data source. Once again click on your smart tag in your GridView and check the boxes next to "Enable paging", "Sort", "Edit", "Delete" (whatever you want). Now save the page and run it. You should see a GridView with the ability to do all this.
To insert you need another control. The DetailsView control is probably the best choice. The steps are almost identical to what you did with the GridView.
Here is the source code that I got after doing all this:
<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString2 %>" DeleteCommand="DELETE FROM `test` WHERE `TestID` = ?TestID" InsertCommand="INSERT INTO `test` (`TestID`, `FirstName`, `LastName`) VALUES (?TestID, ?FirstName, ?LastName)" ProviderName="<%$ ConnectionStrings:testConnectionString2.ProviderName %>" SelectCommand="SELECT * FROM `test`" UpdateCommand="UPDATE `test` SET `FirstName` = ?FirstName, `LastName` = ?LastName WHERE `TestID` = ?TestID"> <DeleteParameters> <asp:Parameter Name="TestID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="FirstName" Type="String" /> <asp:Parameter Name="LastName" Type="String" /> <asp:Parameter Name="TestID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="TestID" Type="Int32" /> <asp:Parameter Name="FirstName" Type="String" /> <asp:Parameter Name="LastName" Type="String" /> </InsertParameters> </asp:SqlDataSource> </div> <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="TestID" DataSourceID="SqlDataSource1"> <Columns> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" /> <asp:BoundField DataField="TestID" HeaderText="TestID" ReadOnly="True" SortExpression="TestID" /> <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" /> </Columns> </asp:GridView> <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="TestID" DataSourceID="SqlDataSource1" Height="50px" Width="125px"> <Fields> <asp:BoundField DataField="FirstName" HeaderText="FirstName" SortExpression="FirstName" /> <asp:BoundField DataField="LastName" HeaderText="LastName" SortExpression="LastName" /> <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowInsertButton="True" /> </Fields> </asp:DetailsView> </form> </body> </html>
All this assumes that you have completed the steps above that will create a connection string for you in your web.config file. Thus, you cannot copy this version of the code and make it work. Do not do without the connection string in your web.config.
There you can do a lot. This site has many great articles and videos about using different data controls. There are also some things to consider when deploying to production. In case this helps, I use GoDaddy and last month I wrote an article about setting up ASP.NET membership using MySql and hosting on GoDaddy. I think the first part of this article may give you some useful hints depending on what you are ultimately trying to do.
This article is here:
http://www.marvinpalmer.com/MarvinPalmer/post/Implement-NET-Membership-and-Roles-using-MySql-Connector-523-on-GoDaddy.aspx
check dis link u can definitely solve the problem ........
http://aspnet.4guysfromrolla.com/articles/021203-1.aspx [without paging]
http://www.aspnetdatagrid.com/Ex/RowInUpDl.aspx [with search call]
Hope this helps.