Showing posts with label populated. Show all posts
Showing posts with label populated. Show all posts

Thursday, March 29, 2012

NEWBIE - Multicolumn Listbox populated from SQL statement

Greetings,

I am attempting to generate a multicolumn listbox from a SQL statement in
ASP.NET. Below is my SQL Statement:

SELECT [PA01101].[PACONTNUMBER], [PA01101].[PAcontname] FROM [PA01101]

I would like a two column list box with [PACONTNUMBER] on the left and
[PAcontname] on the right. I can do this in MS Access with no problem, but
I do not know to get my datareader info into a multicolumn listbox. I can
do one column of data just fine, but cannot add the second column.

Thank you for your help,

-DaveDeclare the listbox on the .aspx page:
<asp:ListBox runat="server" id="LB" /
Then in code-behind, add the items as you iterate through the repeater:
'Get Repeater 'Data'...
While ( Data.Read() )
LB.Items.Add(New ListItem(Data.Item("Field1") + "-" + Data.Item("Field2"), Data.Item("Field1")))
End While

Note: The above code will have [Field1-Field2] as the text field and [Field1] as the value field for each item in the SqlDataReader

"RockNRoll" wrote:

> Greetings,
> I am attempting to generate a multicolumn listbox from a SQL statement in
> ASP.NET. Below is my SQL Statement:
> SELECT [PA01101].[PACONTNUMBER], [PA01101].[PAcontname] FROM [PA01101]
> I would like a two column list box with [PACONTNUMBER] on the left and
> [PAcontname] on the right. I can do this in MS Access with no problem, but
> I do not know to get my datareader info into a multicolumn listbox. I can
> do one column of data just fine, but cannot add the second column.
> Thank you for your help,
> -Dave
>
concatenate two columns into one in your sql query

select column1 + column2 as multicolumn
from mytable

then have your datareader use "multicolumn" as your textfield. You'll probably have to do some spacing on top of this if you want the results in actual columns, but that should be easy enough.

Also there is a third party control that does multi-column listbox and some more stuff
http://easylistbox.com/demoQuickStart.aspx#easy

--Michael

"RockNRoll" <daveweber@.yahoo.com> wrote in message news:eJAoYOkeEHA.3916@.TK2MSFTNGP11.phx.gbl...
> Greetings,
>
> I am attempting to generate a multicolumn listbox from a SQL statement in
> ASP.NET. Below is my SQL Statement:
>
> SELECT [PA01101].[PACONTNUMBER], [PA01101].[PAcontname] FROM [PA01101]
>
> I would like a two column list box with [PACONTNUMBER] on the left and
> [PAcontname] on the right. I can do this in MS Access with no problem, but
> I do not know to get my datareader info into a multicolumn listbox. I can
> do one column of data just fine, but cannot add the second column.
>
> Thank you for your help,
>
> -Dave
>

NEWBIE - Multicolumn Listbox populated from SQL statement

Greetings,
I am attempting to generate a multicolumn listbox from a SQL statement in
ASP.NET. Below is my SQL Statement:
SELECT [PA01101].[PACONTNUMBER], [PA01101].[PAcontname] FROM [PA01101]
I would like a two column list box with [PACONTNUMBER] on the left and
[PAcontname] on the right. I can do this in MS Access with no problem, but
I do not know to get my datareader info into a multicolumn listbox. I can
do one column of data just fine, but cannot add the second column.
Thank you for your help,
-DaveDeclare the listbox on the .aspx page:
<asp:ListBox runat="server" id="LB" />
Then in code-behind, add the items as you iterate through the repeater:
'Get Repeater 'Data'...
While ( Data.Read() )
LB.Items.Add(New ListItem(Data.Item("Field1") + "-" + Data.Item("Field2"), D
ata.Item("Field1")))
End While
Note: The above code will have [Field1-Field2] as the text field and [Field1
] as the value field for each item in the SqlDataReader
"RockNRoll" wrote:

> Greetings,
> I am attempting to generate a multicolumn listbox from a SQL statement in
> ASP.NET. Below is my SQL Statement:
> SELECT [PA01101].[PACONTNUMBER], [PA01101].[PAcontname] FROM [PA01101]
> I would like a two column list box with [PACONTNUMBER] on the left and
> [PAcontname] on the right. I can do this in MS Access with no problem, but
> I do not know to get my datareader info into a multicolumn listbox. I can
> do one column of data just fine, but cannot add the second column.
> Thank you for your help,
> -Dave
>
>
concatenate two columns into one in your sql query
select column1 + column2 as multicolumn
from mytable
then have your datareader use "multicolumn" as your textfield. You'll =
probably have to do some spacing on top of this if you want the results =
in actual columns, but that should be easy enough.
Also there is a third party control that does multi-column listbox and =
some more stuff
http://easylistbox.com/demoQuickStart.aspx#easy
--Michael
"RockNRoll" <daveweber@.yahoo.com> wrote in message =
news:eJAoYOkeEHA.3916@.TK2MSFTNGP11.phx.gbl...
> Greetings,
>=20
> I am attempting to generate a multicolumn listbox from a SQL statement =
in
> ASP.NET. Below is my SQL Statement:
>=20
> SELECT [PA01101].[PACONTNUMBER], [PA01101].[PAcontname] FROM [PA01101]
>=20
> I would like a two column list box with [PACONTNUMBER] on the left and
> [PAcontname] on the right. I can do this in MS Access with no =
problem, but
> I do not know to get my datareader info into a multicolumn listbox. I =
can
> do one column of data just fine, but cannot add the second column.
>=20
> Thank you for your help,
>=20
> -Dave
>=20
>

Friday, March 16, 2012

Newbie needs some help

I'm converting a existing .asp application to ASP.NET using Vb.NET. In my
current asp application I have javascript
grid and its populated from the ASP code using <%=dataitem%> and that
populates the rows in the grid.

How can i use the same grid and populate it with ASP.NET? Can <%= dataitem%>
be used in .NET or is the syntax different now?

NOTE: I want to keep the my current grid because of all the funcionality it
currently has, and after doing some research the Datagrid can't do what my
javascript grid currently does
thanksHi Mike,

Regarding the question, What is the "dataitem", a server side variant? If
so, you can still use same expression in ASP.NET. For example, in code
behind, you have such code:

public dataitem as string

And you can use <%=dataitem%> anywhere in the web form.

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
yes serverside variant

example:

select names from nametable

<%=names%> writes the value of name

"[MSFT]" <lukezhan@.online.microsoft.com> wrote in message
news:IYYc4cWQEHA.1516@.cpmsftngxa10.phx.gbl...
> Hi Mike,
> Regarding the question, What is the "dataitem", a server side variant? If
> so, you can still use same expression in ASP.NET. For example, in code
> behind, you have such code:
> public dataitem as string
> And you can use <%=dataitem%> anywhere in the web form.
> Luke
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
You can still use same expression in ASP.NET. For example:

Public Class WebForm1
Inherits System.Web.UI.Page

Public mydata As String

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

mydata = " some strings "
End Sub

End Class

HTML code:

<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<%= Mydata %>
</form>
</body
Hope this help,

Luke
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Newbie needs some help

I'm converting a existing .asp application to ASP.NET using Vb.NET. In my
current asp application I have javascript
grid and its populated from the ASP code using <%=dataitem%> and that
populates the rows in the grid.
How can i use the same grid and populate it with ASP.NET? Can <%= dataitem%>
be used in .NET or is the syntax different now?
NOTE: I want to keep the my current grid because of all the funcionality it
currently has, and after doing some research the Datagrid can't do what my
javascript grid currently does
thanksHi Mike,
Regarding the question, What is the "dataitem", a server side variant? If
so, you can still use same expression in ASP.NET. For example, in code
behind, you have such code:
public dataitem as string
And you can use <%=dataitem%> anywhere in the web form.
Luke
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
yes serverside variant
example:
select names from nametable
<%=names%> writes the value of name
"[MSFT]" <lukezhan@.online.microsoft.com> wrote in message
news:IYYc4cWQEHA.1516@.cpmsftngxa10.phx.gbl...
> Hi Mike,
> Regarding the question, What is the "dataitem", a server side variant? If
> so, you can still use same expression in ASP.NET. For example, in code
> behind, you have such code:
> public dataitem as string
> And you can use <%=dataitem%> anywhere in the web form.
> Luke
> Microsoft Online Support
> Get Secure! www.microsoft.com/security
> (This posting is provided "AS IS", with no warranties, and confers no
> rights.)
>
You can still use same expression in ASP.NET. For example:
Public Class WebForm1
Inherits System.Web.UI.Page
Public mydata As String
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
mydata = " some strings "
End Sub
End Class
HTML code:
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<%= Mydata %>
</form>
</body>
Hope this help,
Luke
Microsoft Online Support
Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)