<%@ Page Language="vb" %> <%@ Import Namespace="System.Data"%> <%@ Import Namespace="System.Data.SQL"%> <html><head></head> <body> <script runat=server> public sub Page_Load(Source as Object, E as EventArgs) if not Page.IsPostBack then newBind() end if end sub public sub newBind() dim DS as new DataSet dim cmd as SQLDataSetCommand cmd= new SQLDataSetCommand("select * from authors","server=localhost;database=pubs;uid=sa;pwd=") cmd.FillDataSet(DS,"autoren") DataGrid1.DataSource=DS.Tables(0)DefaultView DataGrid1.Databind() end sub public sub editClick(Source as Object, E as DataGridCommandEventArgs) DataGrid1.EditItemIndex=E.Item.ItemIndex newBind() end sub public sub UpdateClick(Source as Object, E as DataGridCommandEventArgs) DataGrid1.EditItemIndex=E.Item.ItemIndex newBind() end sub public sub CancelClick(Source as Object, E as DataGridCommandEventArgs) DataGrid1.EditItemIndex=-1 newBind() end sub </script> <form id="grid1" method="post" runat="server"> <asp:DataGrid id=DataGrid1 runat="server" ForeColor="Black" oneditcommand="editClick" onupdatecommand="updateclick" oncancelcommand="CancelClick" autogeneratecolumns="False"> <property name="Columns"> <asp:EditCommandColumn buttontype="PushButton" canceltext="Abbruch" edittext="Edit" updatetext="Update" /> <asp:boundcolumn datafield="au_id" headertext="ID" readonly="True" /> <asp:boundcolumn datafield="au_fname" headertext="Name" readonly="false" /> <asp:boundcolumn datafield="au_lname" headertext="Name" readonly="false" /> </property> </asp:DataGrid> </form> </body></html>
|