Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. DataList web user control

DataList web user control

Scheduled Pinned Locked Moved ASP.NET
helpwinformstestingbeta-testingtutorial
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    De_Novice
    wrote on last edited by
    #1

    Hi, I am not sure if this is possible. I am exploring web user controls. I have created a datalist user control (datalist.ascx). I have added this control to my default page. Now I want to bind data to this datalist. I am not sure how to do that. I am testing with user controls and any help will be appreciated. Here is my code: default.aspx

    <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default" title="Untitled Page" %>

    <%@ Register Src="datalist.ascx" TagName="datalist" TagPrefix="uc1" %>
    <%@ MasterType VirtualPath="~/MasterPage.master" %>;

    default.aspx.vb

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim cmd As New SqlCommand("ws_Testimonials")
    Try
    If dalaccess.Connect = True Then
    rs1 = dalaccess.GetDataset(cmd, 60)
    dalaccess.Disconnect()
    Datalist1.datasource = rs1
    Datalist1.DataBind()
    End If
    Catch ex As Exception
    End Try

    I get the compilation error that "Error 1 'datasource' is not a member of 'ASP.datalist_ascx'." Gurus please help.

    S 1 Reply Last reply
    0
    • D De_Novice

      Hi, I am not sure if this is possible. I am exploring web user controls. I have created a datalist user control (datalist.ascx). I have added this control to my default page. Now I want to bind data to this datalist. I am not sure how to do that. I am testing with user controls and any help will be appreciated. Here is my code: default.aspx

      <%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Default" title="Untitled Page" %>

      <%@ Register Src="datalist.ascx" TagName="datalist" TagPrefix="uc1" %>
      <%@ MasterType VirtualPath="~/MasterPage.master" %>;

      default.aspx.vb

      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      Dim cmd As New SqlCommand("ws_Testimonials")
      Try
      If dalaccess.Connect = True Then
      rs1 = dalaccess.GetDataset(cmd, 60)
      dalaccess.Disconnect()
      Datalist1.datasource = rs1
      Datalist1.DataBind()
      End If
      Catch ex As Exception
      End Try

      I get the compilation error that "Error 1 'datasource' is not a member of 'ASP.datalist_ascx'." Gurus please help.

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      Just expose the Datalist of your usercontrol using properties. Once done, they will be accessible in the base page and there you can directly access and define the datasource for it.

      Sandeep Mewara [My latest tip/trick] [Forum guidelines]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups