R
RN1
Consider the following code which binds records from a DB to a
Repeater:
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim dSet As DataSet
Dim sqlConn As SqlConnection
Dim sqlDapter As SqlDataAdapter
sqlConn = New SqlConnection(".....")
sqlDapter = New SqlDataAdapter("SELECT * FROM NETUsers",
sqlConn)
dSet = New DataSet()
sqlDapter.Fill(dSet, "Users")
rptrUsers.DataSource = dSet
rptrUsers.DataMember = "Users"
rptrUsers.DataBind()
sqlConn.Close()
End Sub
Sub BindData(ByVal obj As Object, ByVal ea As
RepeaterItemEventArgs)
If (Page.IsPostBack) Then
rptrUsers.DataBind()
End If
End Sub
</script>
<form runat="server">
<asp:Repeater ID="rptrUsers" OnItemDataBound="BindData"
runat="server">
<HeaderTemplate>
<table>
<tr>
<th>NAME</th>
<th>PHONE</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<th>
<asp:LinkButton ID="lnkName" Text='<%# Container.DataItem("FirstName")
& " " & Container.DataItem("LastName") %>' runat="server"></
asp:LinkButton>
</th>
<th><%# Container.DataItem("Phone") %></th>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
When the page loads for the first time, the Repeater displays all the
data from the DB but when I click a LinkButton in the Repeater, I get
an error that says "Server Application Unavailable".
The If condition in the sub named BindData, I believe, is the cause of
the error but why is that line causing the error?
Thanks,
Ron
Repeater:
<script runat="server">
Sub Page_Load(ByVal obj As Object, ByVal ea As EventArgs)
Dim dSet As DataSet
Dim sqlConn As SqlConnection
Dim sqlDapter As SqlDataAdapter
sqlConn = New SqlConnection(".....")
sqlDapter = New SqlDataAdapter("SELECT * FROM NETUsers",
sqlConn)
dSet = New DataSet()
sqlDapter.Fill(dSet, "Users")
rptrUsers.DataSource = dSet
rptrUsers.DataMember = "Users"
rptrUsers.DataBind()
sqlConn.Close()
End Sub
Sub BindData(ByVal obj As Object, ByVal ea As
RepeaterItemEventArgs)
If (Page.IsPostBack) Then
rptrUsers.DataBind()
End If
End Sub
</script>
<form runat="server">
<asp:Repeater ID="rptrUsers" OnItemDataBound="BindData"
runat="server">
<HeaderTemplate>
<table>
<tr>
<th>NAME</th>
<th>PHONE</th>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<th>
<asp:LinkButton ID="lnkName" Text='<%# Container.DataItem("FirstName")
& " " & Container.DataItem("LastName") %>' runat="server"></
asp:LinkButton>
</th>
<th><%# Container.DataItem("Phone") %></th>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
</form>
When the page loads for the first time, the Repeater displays all the
data from the DB but when I click a LinkButton in the Repeater, I get
an error that says "Server Application Unavailable".
The If condition in the sub named BindData, I believe, is the cause of
the error but why is that line causing the error?
Thanks,
Ron