literal Databinding???

Discussion in 'ASP .Net' started by =?Utf-8?B?VGltOjouLg==?=, Jul 21, 2004.

  1. Can someone explain how I create a databinding to a Literal control! I tried doing it as shown below but the reader won't read into the control.

    Thanks


    ...::CODE::..
    Dim Myconn As New SqlConnection(ConfigurationSettings.AppSettings("strConn"))
    Dim cmd As New SqlCommand("PageDetails", Myconn)
    cmd.CommandType = CommandType.StoredProcedure

    Myconn.Open()

    Dim objOfficeName, objID As SqlParameter
    objOfficeName = cmd.Parameters.Add("@OfficeName", SqlDbType.Char)


    objOfficeName.Direction = ParameterDirection.Input


    objOfficeName.Value = "ISC"


    Dim myReader As SqlDataReader = cmd.ExecuteReader()
    importTxt = myReader
    importTxt.DataBind()

    myReader.Close()

    Myconn.Close()
     
    =?Utf-8?B?VGltOjouLg==?=, Jul 21, 2004
    #1
    1. Advertising

  2. =?Utf-8?B?VGltOjouLg==?=

    Teemu Keiski Guest

    Hi,

    it's not databindable that way straight. Instead, you'd set its Text
    property to the text you wish Literal to display.


    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke




    "Tim::.." <myatix_at_hotmail.com> wrote in message
    news:...
    > Can someone explain how I create a databinding to a Literal control! I

    tried doing it as shown below but the reader won't read into the control.
    >
    > Thanks
    >
    >
    > ..::CODE::..
    > Dim Myconn As New

    SqlConnection(ConfigurationSettings.AppSettings("strConn"))
    > Dim cmd As New SqlCommand("PageDetails", Myconn)
    > cmd.CommandType = CommandType.StoredProcedure
    >
    > Myconn.Open()
    >
    > Dim objOfficeName, objID As SqlParameter
    > objOfficeName = cmd.Parameters.Add("@OfficeName", SqlDbType.Char)
    >
    >
    > objOfficeName.Direction = ParameterDirection.Input
    >
    >
    > objOfficeName.Value = "ISC"
    >
    >
    > Dim myReader As SqlDataReader = cmd.ExecuteReader()
    > importTxt = myReader
    > importTxt.DataBind()
    >
    > myReader.Close()
    >
    > Myconn.Close()
     
    Teemu Keiski, Jul 21, 2004
    #2
    1. Advertising

  3. =?Utf-8?B?VGltOjouLg==?=

    Teemu Keiski Guest

    What are you trying to do with this line?

    If objImpCnt Is "" Then


    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke



    "Tim::.." <myatix_at_hotmail.com> wrote in message
    news:...
    > OK! I tried to do what you suggested Teemu but it just doesn't return

    anything! I don't even get an error! Any ideas???
    >
    > Thanks
    >
    > ...
    > Dim myReader As SqlDataReader = cmd.ExecuteReader()
    > While myReader.Read()
    > If objImpCnt Is "" Then
    > importCnt.Visible = True
    > importCnt.Text = myReader("Content")
    > End If
    > End While
    > ' always call Close when done reading.
    > myReader.Close()
    > ' Close the connection when done with it.
    > Myconn.Close()
    > ...
    >
    > "Teemu Keiski" wrote:
    >
    > > Hi,
    > >
    > > it's not databindable that way straight. Instead, you'd set its Text
    > > property to the text you wish Literal to display.
    > >
    > >
    > > --
    > > Teemu Keiski
    > > MCP, Microsoft MVP (ASP.NET), AspInsiders member
    > > ASP.NET Forum Moderator, AspAlliance Columnist
    > > http://blogs.aspadvice.com/joteke
    > >
    > >
    > >
    > >
    > > "Tim::.." <myatix_at_hotmail.com> wrote in message
    > > news:...
    > > > Can someone explain how I create a databinding to a Literal control! I

    > > tried doing it as shown below but the reader won't read into the

    control.
    > > >
    > > > Thanks
    > > >
    > > >
    > > > ..::CODE::..
    > > > Dim Myconn As New

    > > SqlConnection(ConfigurationSettings.AppSettings("strConn"))
    > > > Dim cmd As New SqlCommand("PageDetails", Myconn)
    > > > cmd.CommandType = CommandType.StoredProcedure
    > > >
    > > > Myconn.Open()
    > > >
    > > > Dim objOfficeName, objID As SqlParameter
    > > > objOfficeName = cmd.Parameters.Add("@OfficeName",

    SqlDbType.Char)
    > > >
    > > >
    > > > objOfficeName.Direction = ParameterDirection.Input
    > > >
    > > >
    > > > objOfficeName.Value = "ISC"
    > > >
    > > >
    > > > Dim myReader As SqlDataReader = cmd.ExecuteReader()
    > > > importTxt = myReader
    > > > importTxt.DataBind()
    > > >
    > > > myReader.Close()
    > > >
    > > > Myconn.Close()

    > >
    > >
    > >
     
    Teemu Keiski, Jul 21, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Urbanus
    Replies:
    4
    Views:
    3,415
    Tim Hubberstey
    Jan 12, 2005
  2. les

    asp:literal and hyperlink field

    les, Jul 5, 2003, in forum: ASP .Net
    Replies:
    6
    Views:
    979
    msnews.microsoft.com
    Jul 14, 2003
  3. jobs
    Replies:
    0
    Views:
    1,677
  4. Earl Teigrob
    Replies:
    1
    Views:
    422
    Shravan
    Mar 1, 2004
  5. Anonieko Ramos

    What's wrong with rpc-literal? Why use doc-literal?

    Anonieko Ramos, Sep 27, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    392
    Anonieko Ramos
    Sep 27, 2004
Loading...

Share This Page