This message was discovered on ASPFriends.com 'ngfx-sqlclient' list.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
| Dennis West |
why would this routine return a blank page when the same code worked when in a page load method. now that it is in a function it runs but does not show any datalist items on the page?? Is it because I am using a collection and need to import a namespace?
<%@ Import Namespace="System" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Web" %>
<html> <head>
<script language="VB" runat="server">
Function CreateDataSource() As ICollection ' Create Instance of Connection and Command Object Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As SqlCommand = New SqlCommand("DocumentSearch", myConnection)
' Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC Dim parameterSearch As SqlParameter = New SqlParameter("@Search", SqlDbType.NVarChar, 255) parameterSearch.Value = "" 'Request.Params("txtSearch") myCommand.Parameters.Add(parameterSearch)
' Execute the command myConnection.Open()
DataList1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection) DataList1.DataBind() End Function
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then BindList End If
End Sub
Sub BindList DataList1.DataSource= CreateDataSource() DataList1.DataBind End Sub
Sub DataList_ItemCommand(sender As Object, e As DataListCommandEventArgs) Dim cmd As String = e.CommandSource.CommandName If cmd = "select" Then DataList1.SelectedIndex = e.Item.ItemIndex End If
BindList End Sub
</script> For 2002 ASP.NET Solutions & Articles goto: http://aspalliance.com/dotnetsolutions/
Dennis West West Design MS .NET Developer www. westontheweb.net Click here to reveal e-mail address
|
|
| |
| |
| William \(Bill\) Vaughn (VIP) |
why would this routine return a blank page when the same code worked when in a page load method. now that it is in a function it runs but does not show any datalist items on the page?? Is it because I am using a collection and need to import a namespace?
<%@ Import Namespace="System" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SqlClient" %> <%@ Import Namespace="System.Web" %>
<html> <head>
<script language="VB" runat="server">
Function CreateDataSource() As ICollection ' Create Instance of Connection and Command Object Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim myCommand As SqlCommand = New SqlCommand("DocumentSearch", myConnection)
' Mark the Command as a SPROC myCommand.CommandType = CommandType.StoredProcedure
' Add Parameters to SPROC Dim parameterSearch As SqlParameter = New SqlParameter("@Search", SqlDbType.NVarChar, 255) parameterSearch.Value = "" 'Request.Params("txtSearch") myCommand.Parameters.Add(parameterSearch)
' Execute the command myConnection.Open()
DataList1.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection) DataList1.DataBind() End Function
Sub Page_Load(sender As Object, e As EventArgs)
If Not IsPostBack Then BindList End If
End Sub
Sub BindList DataList1.DataSource= CreateDataSource() DataList1.DataBind End Sub
Sub DataList_ItemCommand(sender As Object, e As DataListCommandEventArgs) Dim cmd As String = e.CommandSource.CommandName If cmd = "select" Then DataList1.SelectedIndex = e.Item.ItemIndex End If
BindList End Sub
</script> For 2002 ASP.NET Solutions & Articles goto: http://aspalliance.com/dotnetsolutions/
Dennis West West Design MS .NET Developer www. westontheweb.net Click here to reveal e-mail address
|
|
| |
|
|
|
|
|