Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2737 connectés 

  FORUM HardWare.fr
  Programmation
  ASP

  asp.net problème de datagrid et command Delete

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

asp.net problème de datagrid et command Delete

n°1329201
lordankou
Posté le 21-03-2006 à 00:18:47  profilanswer
 

voilà je ne comprends pas pourquoi le code correspondant à la commande delete ne s'exécute pas.
j'ai beau regarder sur des codes sources et je ne vois pas mon erreur (la page s'éxécute et quand je clique sur le bouton delete rien ne se passe).
 

Code :
  1. <%@ Page Language="VB" %>
  2. <%@ import Namespace="System.Data" %>
  3. <%@ import Namespace="System.Data.OleDb" %>
  4. <script runat="server">
  5.     ' Insert page code here
  6.     '
  7.     ' function executed when the page is loaded
  8.     sub Page_Load(Sender as Object, E as eventArgs)
  9.         ' check if the page is already load
  10.         if Not Page.isPostBack then
  11.             linkData()
  12.         end if
  13.     end Sub
  14.     ' function to load the list of postgraduate
  15.     sub linkData()
  16.         ' variable declaration
  17.         Dim aConnection As OleDbConnection = new OleDbConnection ' Object to allow a connection between Database and the programm
  18.         Dim aDataAdapter as OleDbDataAdapter = new OleDbDataAdapter ' Object to send the command and retrieve data
  19.         Dim aDataSet as DataSet = new DataSet ' store informations retrieved from a table
  20.         Dim configurationDatabase, querySQL as String ' store the configuration of database and query string
  21.         ' init value
  22.         configurationDatabase = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
  23.                                     & server.mappath("..\database\postgraduate_Student_Manager.mdb" ) ' define the type of database and path to the file
  24.         ' insert group num
  25.         querySQL = "Select * from Postgraduate"
  26.         ' set value
  27.         aConnection.ConnectionString = configurationDatabase  ' apply configuration
  28.         aDataAdapter.selectCommand = new OleDbCommand(QuerySQL,aConnection)
  29.         aDataAdapter.SelectCommand.Connection.Open ' open the connection
  30.         aDataAdapter.Fill(aDataSet,"results" ) ' apply the results in dataset called "Results"
  31.         listPostgraduate.DataSource = aDataSet.Tables("Results" ) ' set the datasource of the datagrid with the results
  32.         Page.DataBind() ' bind the datagrid to the table "result"
  33.     end sub
  34.     Sub Delete(Sender As Object, e As DataGridCommandEventArgs)
  35.         Response.Redirect("departmentCreatePostgradeAccount.aspx" )
  36.     end sub
  37. </script>
  38. <html>
  39. <head>
  40.     <link href="../commonSourceFiles/css/theme1.css" type="text/css" rel="stylesheet" />
  41. </head>
  42. <body>
  43.     <!-- div to show background -->
  44.     <div class="background">
  45.         <form runat="server">
  46.             <!-- div to display login -->
  47.             <div class="log">you are logged as
  48.                 <br />
  49.                 Doudoune ( <a class="logout" href="">logout</a> )
  50.             </div>
  51.             <!-- div to display Menu -->
  52.             <div class="Menu">
  53.                 <table style="WIDTH: 579px; HEIGHT: 29px">
  54.                     <tbody>
  55.                         <tr>
  56.                             <td>
  57.                                 <a class="MenuLien" href="departmentCreatePostgradeAccount.aspx">Postgraduate</a>
  58.                             </td>
  59.                             <td>
  60.                                 <a class="MenuLien" href="departmentAssignTimetable.aspx">Timetable-coordinator</a>
  61.                             </td>
  62.                             <td>
  63.                                 <a class="MenuLien" href="departmentCreateFacultyAccount.aspx">Faculty Members - Supervisor</a>
  64.                             </td>
  65.                             <td>
  66.                                 <a class="MenuLien" href="departmentCreateRoom.aspx">Room</a>
  67.                             </td>
  68.                             <td>
  69.                                 <a class="MenuLien" href="departmentDiversReport.aspx">Divers</a>
  70.                             </td>
  71.                         </tr>
  72.                     </tbody>
  73.                 </table>
  74.             </div>
  75.             <!-- div to display subMenu -->
  76.             <div class="subMenu">
  77.                 <br />
  78.                 <div class="subSubMenu">Actions for postgradutes
  79.                 </div>
  80.                 <br />
  81.                 <!-- create a postgraduate account --><a href="departmentCreatePostgradeAccount.aspx">create
  82.                 <br />
  83.                 postgraduate<br />
  84.                 account </a>
  85.                 <br />
  86.                 <br />
  87.                 <!-- modify a postgraduate account --><a href="departmentModifyPostgradeAccount.aspx">modify
  88.                 <br />
  89.                 postgraduate
  90.                 <br />
  91.                 account </a>
  92.                 <br />
  93.                 <br />
  94.                 <!-- delete a postgraduate account --><a href="departmentDeletePostgradeAccount.aspx">delete
  95.                 <br />
  96.                 postgraduate
  97.                 <br />
  98.                 account </a>
  99.             </div>
  100.             <!-- div to display main part -->
  101.             <div class="corps"><span class="corpsTitle">Delete a postgraduate account</span>
  102.                 <br />
  103.                 <br />
  104.                 <br />
  105.                 <asp:Label id="title" runat="server">List of postgraduate :</asp:Label>
  106.                 <br />
  107.                 <br />
  108.                 <br />
  109.                 <!-- display list of postgraduate -->
  110.                 <!-- structure : ID(hidden column) | first name | last name | button to delete -->
  111.                 <ASP:DataGrid id="listPostgraduate" runat="Server" AllowPaging="True" Font-size="11pt" Font-name="Times new roman" pagerStyle-PrevPageText=" <-- Previous" pagerStyle-NextPageText=" Next -->" backcolor="#DDDDDD" border="1" autoGenerateColumns="False" Font-Names="Times new roman" CellPadding="5" BorderWidth="2px" BorderStyle="Ridge" BorderColor="DarkSlateGray" AllowSorting="True" HorizontalAlign="Center" ForeColor="Black" PageSize="15">
  112.                     <HeaderStyle font-bold="True" wrap="False" horizontalalign="Center" height="16px" forecolor="White" borderstyle="Inset" verticalalign="Middle" backcolor="Gray"></HeaderStyle>
  113.                     <PagerStyle verticalalign="Middle" nextpagetext=" Next &gt;&gt;" font-bold="True" prevpagetext=" &lt;&lt; Previous" horizontalalign="Center" forecolor="White" backcolor="Gray"></PagerStyle>
  114.                     <SelectedItemStyle backcolor="#FFC0C0"></SelectedItemStyle>
  115.                     <AlternatingItemStyle horizontalalign="Center" verticalalign="Bottom" backcolor="White"></AlternatingItemStyle>
  116.                     <ItemStyle horizontalalign="Center" verticalalign="Middle" backcolor="#E0E0E0"></ItemStyle>
  117.                     <Columns>
  118.                         <asp:BoundColumn DataField="ID" HeaderText="IdColumn"></asp:BoundColumn>
  119.                         <asp:HyperLinkColumn Text="First Name Text" DataTextField="FirstName" HeaderText="First Name"></asp:HyperLinkColumn>
  120.                         <asp:HyperLinkColumn Text="Last Name Text" DataTextField="LastName" HeaderText="Last Name"></asp:HyperLinkColumn>
  121.                         <asp:ButtonColumn Text="Delete" ButtonType="PushButton" CommandName="Delete"></asp:ButtonColumn>
  122.                     </Columns>
  123.                 </ASP:DataGrid>
  124.             </div>
  125.             <!-- Insert content here -->
  126.         </form>
  127.     </div>
  128.     <!-- div for contact and last modification -->
  129.     <div class="lastModif">Copyright © 2006 - last modification 7 March, 2006 - University
  130.         of Limerick
  131.         <br />
  132.         <a href="mailto:webmastere@ul.ie">webmaster</a>
  133.         <p>
  134.             <!-- css validator --><a href="http://jigsaw.w3.org/css-validator/validator?uri=http://localhost/theme1.css"><img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; WIDTH: 88px; BORDER-BOTTOM: 0px; HEIGHT: 31px" alt="Valid CSS!" src="http://jigsaw.w3.org/css-validator/images/vcss" /> </a>
  135.         </p>
  136.     </div>
  137. </body>
  138. </html>


 
Si quelqu'un pouvait m'aider ça serait sympa car là je bloque totalement.

mood
Publicité
Posté le 21-03-2006 à 00:18:47  profilanswer
 


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  ASP

  asp.net problème de datagrid et command Delete

 

Sujets relatifs
problème de lien de messagerieproblème case à cocher et bouton radio
Problème avec MAXLENGTHProbleme incompréhensible ou j'ai du mal
Probleme de relation entre tablesproblème conception table (problème clé primaire)
Problème de lien pop up qui change page de base :sProblème sur mon ftp !
problème avec une ouverture de ficheir texteProblème pour passer d'une page à une autre sur forum phpbb
Plus de sujets relatifs à : asp.net problème de datagrid et command Delete


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR