473,396 Members | 2,068 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

literal Databinding???

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("s trConn"))
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()
Nov 18 '05 #1
2 1720
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:1C**********************************@microsof t.com...
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("s trConn")) 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()

Nov 18 '05 #2
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:C2**********************************@microsof t.com...
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:1C**********************************@microsof t.com...
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("s trConn"))
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()


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Moe Sizlak | last post by:
Hi, Can I check a checkbox by default based on the value returned from a database? for example if the value (dr("frm7value")) returned from a db field is "YES" how can I check the checkbox by...
3
by: John Bailey | last post by:
When I first built a few web pages in ASP .Net 2.0, I thought it was great. The formview and detailview contorls would automatically layout the controls for you, the update methods were...
4
by: Nathan Sokalski | last post by:
I have two databinding expressions (the first & last names from a DB) that I want to assign to the text property of a Label so that the result is LASTNAME,FIRSTNAME. At the moment, I have the...
9
by: Dennis | last post by:
I have tried using Databinding for my application but always seem to find it very restrictive (maybe I don't completely understand it enough). I always seem to find it much easier to display a...
8
by: GaryDean | last post by:
We have been noticing that questions on vs.2005/2.0 don't appear to get much in answers so I'm reposting some questions posted by some of the programmers here in our organization that never got...
0
by: Wayne Sepega | last post by:
I have the following Object DataSource <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" SelectMethod="GetCustomer" TypeName="Customers" DataObjectTypeName="Customer"...
2
by: Paul | last post by:
Hi all, I have a custom control with an overridden Render method. Inside this method I'm rendering each control in its collection using their RenderControl method. However, I'm running into a...
8
by: Dirk | last post by:
Hello, I have a problem to use databinding with my business layer classes. My data class does not have simple properties (string, int or datetime), instead, all my properties are objects of the...
1
by: =?Utf-8?B?QWxoYW1icmEgRWlkb3MgS2lxdWVuZXQ=?= | last post by:
Hello to all, I want to know if DataBinding in asp.net 2,0 is better than to fill up the values of the controls of the following form: this.miControlTextBox.Text = valorParaControlTextbox; ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.