How to trigger subroutine???

I

icloud

Guest
I'm the beginner of ASP.net.
The subroutine "updatedb" cannt be triggered when I click the botton in asp:repeater. Why? what's wrong?
===========================================

<%@ Import Namespace="System.Data.OleDb" %>
<%@ Import Namespace="System.Data" %>

<script language="VB" runat="server">
sub Page_Load
dim conn, sql, comm, read
conn=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; data source=" & server.mappath("sales.mdb"))
conn.Open()

sql="SELECT * FROM product"
comm=New OleDbCommand(sql,conn)
read=comm.ExecuteReader()

product.DataSource=read
product.DataBind()

read.Close()
conn.Close()
end sub

Sub updatedb(s As Object, e As RepeaterCommandEventArgs)
Response.Write("abc") '--> Nothing
....
....
....
end sub

</script>

<html>
<body>
<form runat="server">

<asp:Repeater id="product" runat="server" OnItemCommand="updatedb">

<HeaderTemplate>
<table border="1" width="400">
<tr><font size="4">ABC Company</font></tr>
<tr>&nbsp;</tr>
<tr>
<th>PID</th>
<th>PDesc</th>
<th>Price</th>
<th>Quantity</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td width="100"><ASP:TextBox id="pid" runat="server" Text=<%#Container.DataItem("PID")%>/></td>
<td width="100"><ASP:TextBox id="pdesc" runat="server" Text=<%#Container.DataItem("PDesc")%>/></td>
<td width="100"><ASP:TextBox id="price" runat="server" Text=<%#Container.DataItem("Price")%>/></td>
<td width="100"><ASP:TextBox id="quantity" runat="server" Text=<%#Container.DataItem("Quantity")%>/></td>
<td width="100"></td>
</tr>
</ItemTemplate>

<FooterTemplate>
</table>
<asp:Button id="btn0" Text="Update" runat="server" class="botton"/>
</FooterTemplate>

</asp:Repeater>
</form>

</body>
</html>
 
Try updating the button code to include an action to start your subroutine on -

<asp:Button id="btn0" Text="Update" runat="server" class="botton" OnClick="updatedb"/>

Paul
 
This is pretty much page 1 of any ASP.NET book. You need to understand how to create an event trigger and setup an event handler for the button.
-Dave
 
Back
Top