Showing posts with label server. Show all posts
Showing posts with label server. Show all posts

Thursday, March 29, 2012

Pop Up Window with Server.Transfer

Hi,

In one of my asp.net page, when users click on a button, I am using Server.Transfer to redirect user to another page and pass all the info to that page asServer.Transfer("TripDetails.aspx").

I need to open a new window and pass all the info to new page. How can I achive this? How can I open a new window and useServer.Transfer at the same time?

Thanks

On the click event of the button you'll need to open a new window there using javascript like window.open. If the button is submitting a form you can set the TARGET of the FORM to be _blank;

<FORM target="_blank" action="...">


Thanks Aidy, it works for me.

pop up window using javascript

hi how can I open this link in new pop up window using javascript?
<asp:HyperLink id="HLink_Amex" runat="server" NavigateUrl="images/cvv_amex.g
if">Amex?</asp:HyperLink>
mahsamahsa,
Try set Target=_blank
Thomas Andersson
"mahsa" wrote:

> hi how can I open this link in new pop up window using javascript?
> <asp:HyperLink id="HLink_Amex" runat="server" NavigateUrl="images/cvv_amex
.gif">Amex?</asp:HyperLink>
> --
> mahsa
And if you're not generating the URL or the HyperLink control dynamically in
code, you might be better off using a standard HTML Anchor as in
<A href="http://links.10026.com/?link=images/cvv_amex.gif" target="_blank">Amex?</A>
Why have a runat="server" when the server isn't adding anything to the
picture? It's a waste of server resources.
Dale Preston
MCAD, MCSE, MCDBA
"crexes" <crexes@.discussions.microsoft.com> wrote in message
news:902C6D44-D451-411B-A69B-50C1C2DE30FF@.microsoft.com...
> mahsa,
> Try set Target=_blank
> Thomas Andersson
> "mahsa" wrote:
>
NavigateUrl="images/cvv_amex.gif">Amex?</asp:HyperLink>

pop up window using javascript

hi how can I open this link in new pop up window using javascript?
<asp:HyperLink id="HLink_Amex" runat="server" NavigateUrl="images/cvv_amex.gif">Amex?</asp:HyperLink
--
mahsamahsa,

Try set Target=_blank

Thomas Andersson

"mahsa" wrote:

> hi how can I open this link in new pop up window using javascript?
> <asp:HyperLink id="HLink_Amex" runat="server" NavigateUrl="images/cvv_amex.gif">Amex?</asp:HyperLink>
> --
> mahsa
And if you're not generating the URL or the HyperLink control dynamically in
code, you might be better off using a standard HTML Anchor as in

<A href="http://links.10026.com/?link=images/cvv_amex.gif" target="_blank">Amex?</A
Why have a runat="server" when the server isn't adding anything to the
picture? It's a waste of server resources.

Dale Preston
MCAD, MCSE, MCDBA

"crexes" <crexes@.discussions.microsoft.com> wrote in message
news:902C6D44-D451-411B-A69B-50C1C2DE30FF@.microsoft.com...
> mahsa,
> Try set Target=_blank
> Thomas Andersson
> "mahsa" wrote:
> > hi how can I open this link in new pop up window using javascript?
> > <asp:HyperLink id="HLink_Amex" runat="server"
NavigateUrl="images/cvv_amex.gif">Amex?</asp:HyperLink>
> > --
> > mahsa

POP3 Mail Retrival- Does any one has source code?

Hi,
I am wondering if anyone has the source code (in C# or VB.net) to retrive
pop emails from the server. Please DO NOT suggest with somesort of component
solution because I can not trust the dlls (sorry for being rude!)
Thanks in advance. Your help is appreciated.
ProdipIs there any source code here that suits your needs?
http://www.gotdotnet.com/community/...aspx?query=pop3
"Prodip Saha" <psaha@.bear.com> wrote in message
news:ObSg2kqHFHA.3588@.TK2MSFTNGP14.phx.gbl...
> Hi,
> I am wondering if anyone has the source code (in C# or VB.net) to retrive
> pop emails from the server. Please DO NOT suggest with somesort of
> component
> solution because I can not trust the dlls (sorry for being rude!)
> Thanks in advance. Your help is appreciated.
> Prodip
>
Thanks, Ken. This will give me the needed materials/helps.
Prodip
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:eIqODc1HFHA.2860@.TK2MSFTNGP12.phx.gbl...
> Is there any source code here that suits your needs?
> http://www.gotdotnet.com/community/...aspx?query=pop3
> "Prodip Saha" <psaha@.bear.com> wrote in message
> news:ObSg2kqHFHA.3588@.TK2MSFTNGP14.phx.gbl...
retrive
>

POP3 Mail Retrival- Does any one has source code?

Hi,
I am wondering if anyone has the source code (in C# or VB.net) to retrive
pop emails from the server. Please DO NOT suggest with somesort of component
solution because I can not trust the dlls (sorry for being rude!)

Thanks in advance. Your help is appreciated.
ProdipIs there any source code here that suits your needs?

http://www.gotdotnet.com/community/...aspx?query=pop3

"Prodip Saha" <psaha@.bear.com> wrote in message
news:ObSg2kqHFHA.3588@.TK2MSFTNGP14.phx.gbl...
> Hi,
> I am wondering if anyone has the source code (in C# or VB.net) to retrive
> pop emails from the server. Please DO NOT suggest with somesort of
> component
> solution because I can not trust the dlls (sorry for being rude!)
> Thanks in advance. Your help is appreciated.
> Prodip
Thanks, Ken. This will give me the needed materials/helps.
Prodip
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:eIqODc1HFHA.2860@.TK2MSFTNGP12.phx.gbl...
> Is there any source code here that suits your needs?
> http://www.gotdotnet.com/community/...aspx?query=pop3
> "Prodip Saha" <psaha@.bear.com> wrote in message
> news:ObSg2kqHFHA.3588@.TK2MSFTNGP14.phx.gbl...
> > Hi,
> > I am wondering if anyone has the source code (in C# or VB.net) to
retrive
> > pop emails from the server. Please DO NOT suggest with somesort of
> > component
> > solution because I can not trust the dlls (sorry for being rude!)
> > Thanks in advance. Your help is appreciated.
> > Prodip

Monday, March 26, 2012

Populate a label with text from a drop down list box

I know this is probably real easy but I can't figure it out.
I'm trying to grab the text that appears in a drop down list server control
and place it in a label server control on the same page. I can get the
selected value, that's easy. But I want the text.
Thanksddl.SelectedItem.Text
Eliyahu
"Mardy" <Mardy@.discussions.microsoft.com> wrote in message
news:983E0BF1-2741-4B22-920F-6F7708CA712B@.microsoft.com...
> I know this is probably real easy but I can't figure it out.
> I'm trying to grab the text that appears in a drop down list server
control
> and place it in a label server control on the same page. I can get the
> selected value, that's easy. But I want the text.
> Thanks
>

Populate a label with text from a drop down list box

I know this is probably real easy but I can't figure it out.

I'm trying to grab the text that appears in a drop down list server control
and place it in a label server control on the same page. I can get the
selected value, that's easy. But I want the text.

Thanksddl.SelectedItem.Text

Eliyahu

"Mardy" <Mardy@.discussions.microsoft.com> wrote in message
news:983E0BF1-2741-4B22-920F-6F7708CA712B@.microsoft.com...
> I know this is probably real easy but I can't figure it out.
> I'm trying to grab the text that appears in a drop down list server
control
> and place it in a label server control on the same page. I can get the
> selected value, that's easy. But I want the text.
> Thanks

Saturday, March 24, 2012

Populate Dropdown from SQL Server

Hello everyone!
I'm trying to populate a dropdown list from SQL Server but it's not
being populated. I've tried all sorts of suggestions and examples that
I found from Google but I just can not get it to work. I am able to
access the database from other pages and display a list of records, but
I just can't get the data to go into the dd list.
Below is my code:
ASPX
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false"
CodeFile="addApplication.aspx.vb" Inherits="addApplication" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddlAgency" runat="server"
DataTextField="agName" DataValueField="agID" />
</div>
</form>
</body>
</html>
VB (code behind)
Partial Class addApplication
Inherits System.Web.UI.Page
Public Sub Page_click(ByVal sender As Object, ByVal e As EventArgs)
'Create a connection string
Dim conStr As String =
ConfigurationManager.ConnectionStrings("connString").ConnectionString
' connString is defined in web.config and works on other pages within
the website project
'Open a connection
Dim objConnection As OleDbConnection
objConnection = New OleDbConnection(conStr)
objConnection.Open()
'Specify the SQL string
Dim strSQL As String = "SELECT * FROM tblAgency;"
'Create a command object
Dim objCommand As OleDbCommand
objCommand = New OleDbCommand(strSQL, objConnection)
'Get a datareader
Dim objDataReader As OleDbDataReader
objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConnection)
ddlAgency.DataSource = objDataReader
ddlAgency.DataBind()
'Close the datareader/db connection
objDataReader.Close()
End Sub
End Class
Is there something I'm doing wrong here?
thanks,
JerryWith Me.ddlSendDepartment
.DataSource = tblScreen
.DataTextField = "DepartmentName"
.DataValueField = "DepartmentID"
. DataBind()
End With
"Jerry" <jerryalan@.gmail.com> wrote in message
news:1147987219.226284.39470@.j55g2000cwa.googlegroups.com...
> Hello everyone!
> I'm trying to populate a dropdown list from SQL Server but it's not
> being populated. I've tried all sorts of suggestions and examples that
> I found from Google but I just can not get it to work. I am able to
> access the database from other pages and display a list of records, but
> I just can't get the data to go into the dd list.
> Below is my code:
> ASPX
> <%@. Page Language="VB" AutoEventWireup="false"
> CodeFile="addApplication.aspx.vb" Inherits="addApplication" %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:DropDownList ID="ddlAgency" runat="server"
> DataTextField="agName" DataValueField="agID" />
> </div>
> </form>
> </body>
> </html>
> VB (code behind)
> Partial Class addApplication
> Inherits System.Web.UI.Page
> Public Sub Page_click(ByVal sender As Object, ByVal e As EventArgs)
> 'Create a connection string
> Dim conStr As String =
> ConfigurationManager.ConnectionStrings("connString").ConnectionString
> ' connString is defined in web.config and works on other pages within
> the website project
> 'Open a connection
> Dim objConnection As OleDbConnection
> objConnection = New OleDbConnection(conStr)
> objConnection.Open()
> 'Specify the SQL string
> Dim strSQL As String = "SELECT * FROM tblAgency;"
> 'Create a command object
> Dim objCommand As OleDbCommand
> objCommand = New OleDbCommand(strSQL, objConnection)
> 'Get a datareader
> Dim objDataReader As OleDbDataReader
> objDataReader =
> objCommand.ExecuteReader(CommandBehavior.CloseConnection)
> ddlAgency.DataSource = objDataReader
> ddlAgency.DataBind()
> 'Close the datareader/db connection
> objDataReader.Close()
> End Sub
> End Class
> Is there something I'm doing wrong here?
> thanks,
> --
> Jerry
>
Thanks for the reply Jeff. I tried your suggestion but I wasn't
successfull.
With Me.ddlAgency
.DataSource = objDataReader
.DataTextField = "agName"
.DataValueField = "agID"
.DataBind()
End With
'ddlAgency.DataSource = objDataReader
'ddlAgency.DataBind()
Did I do it wrong?
Jerry
Doh! I caught the mistake. I had the code in the click event handler
and not the page load handler.
Thanks Jeff, your suggestion does work.
Jerry

Populate Dropdown from SQL Server

Hello everyone!

I'm trying to populate a dropdown list from SQL Server but it's not
being populated. I've tried all sorts of suggestions and examples that
I found from Google but I just can not get it to work. I am able to
access the database from other pages and display a list of records, but
I just can't get the data to go into the dd list.

Below is my code:

ASPX
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false"
CodeFile="addApplication.aspx.vb" Inherits="addApplication" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:DropDownList ID="ddlAgency" runat="server"
DataTextField="agName" DataValueField="agID" />
</div>
</form>
</body>
</html
VB (code behind)

Partial Class addApplication
Inherits System.Web.UI.Page

Public Sub Page_click(ByVal sender As Object, ByVal e As EventArgs)
'Create a connection string

Dim conStr As String =
ConfigurationManager.ConnectionStrings("connString").ConnectionString

' connString is defined in web.config and works on other pages within
the website project

'Open a connection
Dim objConnection As OleDbConnection
objConnection = New OleDbConnection(conStr)
objConnection.Open()

'Specify the SQL string
Dim strSQL As String = "SELECT * FROM tblAgency;"

'Create a command object
Dim objCommand As OleDbCommand
objCommand = New OleDbCommand(strSQL, objConnection)

'Get a datareader
Dim objDataReader As OleDbDataReader
objDataReader =
objCommand.ExecuteReader(CommandBehavior.CloseConn ection)

ddlAgency.DataSource = objDataReader
ddlAgency.DataBind()

'Close the datareader/db connection
objDataReader.Close()
End Sub
End Class

Is there something I'm doing wrong here?

thanks,

--
JerryWith Me.ddlSendDepartment

.DataSource = tblScreen

.DataTextField = "DepartmentName"

.DataValueField = "DepartmentID"

.. DataBind()

End With

"Jerry" <jerryalan@.gmail.com> wrote in message
news:1147987219.226284.39470@.j55g2000cwa.googlegro ups.com...
> Hello everyone!
> I'm trying to populate a dropdown list from SQL Server but it's not
> being populated. I've tried all sorts of suggestions and examples that
> I found from Google but I just can not get it to work. I am able to
> access the database from other pages and display a list of records, but
> I just can't get the data to go into the dd list.
> Below is my code:
> ASPX
> <%@. Page Language="VB" AutoEventWireup="false"
> CodeFile="addApplication.aspx.vb" Inherits="addApplication" %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <asp:DropDownList ID="ddlAgency" runat="server"
> DataTextField="agName" DataValueField="agID" />
> </div>
> </form>
> </body>
> </html>
> VB (code behind)
> Partial Class addApplication
> Inherits System.Web.UI.Page
> Public Sub Page_click(ByVal sender As Object, ByVal e As EventArgs)
> 'Create a connection string
> Dim conStr As String =
> ConfigurationManager.ConnectionStrings("connString").ConnectionString
> ' connString is defined in web.config and works on other pages within
> the website project
> 'Open a connection
> Dim objConnection As OleDbConnection
> objConnection = New OleDbConnection(conStr)
> objConnection.Open()
> 'Specify the SQL string
> Dim strSQL As String = "SELECT * FROM tblAgency;"
> 'Create a command object
> Dim objCommand As OleDbCommand
> objCommand = New OleDbCommand(strSQL, objConnection)
> 'Get a datareader
> Dim objDataReader As OleDbDataReader
> objDataReader =
> objCommand.ExecuteReader(CommandBehavior.CloseConn ection)
> ddlAgency.DataSource = objDataReader
> ddlAgency.DataBind()
> 'Close the datareader/db connection
> objDataReader.Close()
> End Sub
> End Class
> Is there something I'm doing wrong here?
> thanks,
> --
> Jerry
Thanks for the reply Jeff. I tried your suggestion but I wasn't
successfull.

With Me.ddlAgency
.DataSource = objDataReader
.DataTextField = "agName"
.DataValueField = "agID"
.DataBind()
End With

'ddlAgency.DataSource = objDataReader
'ddlAgency.DataBind()

Did I do it wrong?

--
Jerry
Doh! I caught the mistake. I had the code in the click event handler
and not the page load handler.

Thanks Jeff, your suggestion does work.

--
Jerry

Populate dropdown list with XML

How can I fill a dropdown list with XML data. Simplest way please. I would like to user server.mappath to get the data from the file. Is it possible to use a recordset

I need to populate the ID and the value of the record.

Code sample appreciated...thanksPlease see below code, that helps for your question.

Here is the simple XML file, I am using to bind to dropdownlist and name is as Xmlfile.xml


<?xml version="1.0" encoding="utf-8" ?>
<DataList>
<Student>
<Name>Creator</Name >
<Roll>101</Roll >
</Student >
<Student>
<Name>Maintainer</Name >
<Roll>102</Roll >
</Student
</DataList>

and I am using this file to bind with Dropdownlost in page load event. Assuming DropDownList server control name is DropDownList1


Dim Ds As New System.Data.DataSet
Ds.ReadXml("D:\WebSites\VS2005First\XMLFile.xml")

DropDownList1.DataSource = Ds.Tables(0).DefaultView
DropDownList1.DataTextField = "Roll"
DropDownList1.DataValueField = "Name"
DropDownList1.DataBind()

Hope this helps you!
ok that is pretty easy,fist of all u need to populate ur xml data to your datagrid then bind it to ur dropdownlist.

xml file
<root>
<userName>Bob</userName>
<userID>1</userID>
</root
vb.net
'read your data from your datagrid
'assuming ur xml is your root directory
'

Dim ds As DataSet
ds.ReadXml(Server.MapPath("file.xml"))
'bind your dataset to your dropdown list
DropDownList1.DataSource = ds
'assign the element of ur xml to the ddl
DropDownList1.DataTextField = "userName"
DropDownList1.DataValueField = "userID"
DropDownList1.DataBind()

hope that help.Happy coding
Thank you all for replying - I will try the suggestions given

populate DropDownList from DB

Hi,
Could someone tell me how can be populated DropdownList from Data Base. I
use ASP.NET/C#/MS SQL SERVER.
Thanks!
Viktor
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.721 / Virus Database: 477 - Release Date: 16.7.2004 a.Victor,
You need to get the database data into a dataset, set the DropdownList
properties DataSource to the dataset name and DataMember to the table name
and call DataBind method.
Eliyahu
"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:OMEUyaGdEHA.212@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Could someone tell me how can be populated DropdownList from Data Base. I
> use ASP.NET/C#/MS SQL SERVER.
> Thanks!
> Viktor
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.721 / Virus Database: 477 - Release Date: 16.7.2004 a.
>
Thanks for the reply!
Could you add the other code?
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);
DataSet ds = new DataSet();
da.Fill (ds,"Table");
DropDownList2.DataSource = ds;
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
DropDownList2.DataMember = "Table";
DataBind (); // or DropDownList2.DataBind ();
"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:%23QdEA%23HdEHA.2664@.TK2MSFTNGP09.phx.gbl...
> Thanks for the reply!
> Could you add the other code?
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
> conn);
>
> DataSet ds = new DataSet();
> da.Fill (ds,"Table");
> DropDownList2.DataSource = ds;
>
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
>
>
Hi, Thanks again for the reply! I wrote that but it doesn't work. Could you
check for an error?
Thanks
private void Page_Load(object sender, System.EventArgs e)
{
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);
DataSet ds = new DataSet();
da.Fill (ds,"Table");
DropDownList2.DataSource = ds;
DropDownList2.DataMember = "Table";
DropDownList2.DataBind () ;
}
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
see inline
"Viktor Popov" <viketo@.yahoo.com> wrote in message news:O5PJdnIdEHA.3616@.TK2MSFTNGP10.phx.g
bl...
> Hi, Thanks again for the reply! I wrote that but it doesn't work. Could yo
u
> check for an error?
> Thanks
> private void Page_Load(object sender, System.EventArgs e)
> {
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
> conn);
>
> DataSet ds = new DataSet();
> da.Fill (ds,"Table");
> DropDownList2.DataSource = ds;
> DropDownList2.DataMember = "Table";
> DropDownList2.DataBind () ;
>
add the code (with the correct values):
DropDownList2.DataTextField = "<name of column for visible text>";
DropDownList2.DataValueField = "<name of column for internal value>";

> }
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
>
I tryed to do that:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);
conn.Open();
da.SelectCommand.ExecuteReader();
DataSet ds = new DataSet();
da.Fill (ds,"Table");
DropDownList2.DataSource = ds;
DropDownList2.DataMember = "Table";
DropDownList2.DataTextField = "TypeOffer";
DropDownList2.DataValueField = "OfferID";
DropDownList2.DataBind () ;]
}
but it doesn't work.
What could I do?
Thanks!
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
what's the error?
"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:OHTu$fJdEHA.1384@.TK2MSFTNGP10.phx.gbl...
> I tryed to do that:
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer
",
> conn);
> conn.Open();
> da.SelectCommand.ExecuteReader();
> DataSet ds = new DataSet();
> da.Fill (ds,"Table");
> DropDownList2.DataSource = ds;
> DropDownList2.DataMember = "Table";
> DropDownList2.DataTextField = "TypeOffer";
> DropDownList2.DataValueField = "OfferID";
> DropDownList2.DataBind () ;]
> }
> but it doesn't work.
> What could I do?
> Thanks!
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
>
There is no error. When I start the application the DropDownList is empty.
There are no values, no items. My table is full with data
TypeOffer
--
OfferID TypeOffer
1 rent
2 sell
3 change
Do you know what's wrong?
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:eahN5iJdEHA.2664@.TK2MSFTNGP09.phx.gbl...
> what's the error?
> "Viktor Popov" <viketo@.yahoo.com> wrote in message
> news:OHTu$fJdEHA.1384@.TK2MSFTNGP10.phx.gbl...
blek.TypeOffer
> ",
>
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
Can set a breakpoint after the line with da.Fill (ds,"Table"); and check if
the dataset actually gets any data?
"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:%231PE14JdEHA.2544@.TK2MSFTNGP10.phx.gbl...
> There is no error. When I start the application the DropDownList is empty.
> There are no values, no items. My table is full with data
> TypeOffer
> --
> OfferID TypeOffer
> 1 rent
> 2 sell
> 3 change
> Do you know what's wrong?
> "Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
> news:eahN5iJdEHA.2664@.TK2MSFTNGP09.phx.gbl...
> blek.TypeOffer
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
>

populate DropDownList from DB

Hi,
Could someone tell me how can be populated DropdownList from Data Base. I
use ASP.NET/C#/MS SQL SERVER.

Thanks!

Viktor

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.721 / Virus Database: 477 - Release Date: 16.7.2004 a.Victor,

You need to get the database data into a dataset, set the DropdownList
properties DataSource to the dataset name and DataMember to the table name
and call DataBind method.

Eliyahu

"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:OMEUyaGdEHA.212@.TK2MSFTNGP12.phx.gbl...
> Hi,
> Could someone tell me how can be populated DropdownList from Data Base. I
> use ASP.NET/C#/MS SQL SERVER.
> Thanks!
> Viktor
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.721 / Virus Database: 477 - Release Date: 16.7.2004 a.
Thanks for the reply!

Could you add the other code?

SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");

SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);

DataSet ds = new DataSet();

da.Fill (ds,"Table");

DropDownList2.DataSource = ds;

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
DropDownList2.DataMember = "Table";
DataBind (); // or DropDownList2.DataBind ();

"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:%23QdEA%23HdEHA.2664@.TK2MSFTNGP09.phx.gbl...
> Thanks for the reply!
> Could you add the other code?
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
> conn);
>
> DataSet ds = new DataSet();
> da.Fill (ds,"Table");
> DropDownList2.DataSource = ds;
>
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
Hi, Thanks again for the reply! I wrote that but it doesn't work. Could you
check for an error?

Thanks

private void Page_Load(object sender, System.EventArgs e)

{

SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");

SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);

DataSet ds = new DataSet();

da.Fill (ds,"Table");

DropDownList2.DataSource = ds;

DropDownList2.DataMember = "Table";

DropDownList2.DataBind () ;

}

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
see inline

"Viktor Popov" <viketo@.yahoo.com> wrote in message news:O5PJdnIdEHA.3616@.TK2MSFTNGP10.phx.gbl...
> Hi, Thanks again for the reply! I wrote that but it doesn't work. Could you
> check for an error?
> Thanks
> private void Page_Load(object sender, System.EventArgs e)
> {
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
> conn);
>
> DataSet ds = new DataSet();
> da.Fill (ds,"Table");
> DropDownList2.DataSource = ds;
> DropDownList2.DataMember = "Table";
> DropDownList2.DataBind () ;

add the code (with the correct values):
DropDownList2.DataTextField = "<name of column for visible text>";
DropDownList2.DataValueField = "<name of column for internal value>";

> }
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
I tryed to do that:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer ",
conn);
conn.Open();
da.SelectCommand.ExecuteReader();
DataSet ds = new DataSet();
da.Fill (ds,"Table");
DropDownList2.DataSource = ds;
DropDownList2.DataMember = "Table";
DropDownList2.DataTextField = "TypeOffer";
DropDownList2.DataValueField = "OfferID";
DropDownList2.DataBind () ;]
}

but it doesn't work.
What could I do?

Thanks!

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
what's the error?

"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:OHTu$fJdEHA.1384@.TK2MSFTNGP10.phx.gbl...
> I tryed to do that:
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter da = new SqlDataAdapter ("Select * FROM blek.TypeOffer
",
> conn);
> conn.Open();
> da.SelectCommand.ExecuteReader();
> DataSet ds = new DataSet();
> da.Fill (ds,"Table");
> DropDownList2.DataSource = ds;
> DropDownList2.DataMember = "Table";
> DropDownList2.DataTextField = "TypeOffer";
> DropDownList2.DataValueField = "OfferID";
> DropDownList2.DataBind () ;]
> }
> but it doesn't work.
> What could I do?
> Thanks!
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
There is no error. When I start the application the DropDownList is empty.
There are no values, no items. My table is full with data
TypeOffer
-------
OfferID TypeOffer
1 rent
2 sell
3 change

Do you know what's wrong?
"Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
news:eahN5iJdEHA.2664@.TK2MSFTNGP09.phx.gbl...
> what's the error?
> "Viktor Popov" <viketo@.yahoo.com> wrote in message
> news:OHTu$fJdEHA.1384@.TK2MSFTNGP10.phx.gbl...
> > I tryed to do that:
> > private void Page_Load(object sender, System.EventArgs e)
> > {
> > // Put user code to initialize the page here
> > SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> > Catalog=Estate; User ID=blek; Password=banderas");
> > SqlDataAdapter da = new SqlDataAdapter ("Select * FROM
blek.TypeOffer
> ",
> > conn);
> > conn.Open();
> > da.SelectCommand.ExecuteReader();
> > DataSet ds = new DataSet();
> > da.Fill (ds,"Table");
> > DropDownList2.DataSource = ds;
> > DropDownList2.DataMember = "Table";
> > DropDownList2.DataTextField = "TypeOffer";
> > DropDownList2.DataValueField = "OfferID";
> > DropDownList2.DataBind () ;]
> > }
> > but it doesn't work.
> > What could I do?
> > Thanks!
> > --
> > Outgoing mail is certified Virus Free.
> > Checked by AVG anti-virus system (http://www.grisoft.com).
> > Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
Can set a breakpoint after the line with da.Fill (ds,"Table"); and check if
the dataset actually gets any data?

"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:%231PE14JdEHA.2544@.TK2MSFTNGP10.phx.gbl...
> There is no error. When I start the application the DropDownList is empty.
> There are no values, no items. My table is full with data
> TypeOffer
> -------
> OfferID TypeOffer
> 1 rent
> 2 sell
> 3 change
> Do you know what's wrong?
> "Eliyahu Goldin" <removemeegoldin@.monarchmed.com> wrote in message
> news:eahN5iJdEHA.2664@.TK2MSFTNGP09.phx.gbl...
> > what's the error?
> > "Viktor Popov" <viketo@.yahoo.com> wrote in message
> > news:OHTu$fJdEHA.1384@.TK2MSFTNGP10.phx.gbl...
> > > I tryed to do that:
> > > private void Page_Load(object sender, System.EventArgs e)
> > > {
> > > // Put user code to initialize the page here
> > > > SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> > > Catalog=Estate; User ID=blek; Password=banderas");
> > > SqlDataAdapter da = new SqlDataAdapter ("Select * FROM
> blek.TypeOffer
> > ",
> > > conn);
> > > conn.Open();
> > > da.SelectCommand.ExecuteReader();
> > > DataSet ds = new DataSet();
> > > da.Fill (ds,"Table");
> > > DropDownList2.DataSource = ds;
> > > DropDownList2.DataMember = "Table";
> > > DropDownList2.DataTextField = "TypeOffer";
> > > DropDownList2.DataValueField = "OfferID";
> > > DropDownList2.DataBind () ;]
> > > }
> > > > but it doesn't work.
> > > What could I do?
> > > > Thanks!
> > > > > --
> > > Outgoing mail is certified Virus Free.
> > > Checked by AVG anti-virus system (http://www.grisoft.com).
> > > Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
> > >
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
It doesn't work...I'm stucked....
My last code is this. When I RUN it there are no errors but the DropDownList
is not populated and the msg.Text=""

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here

SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
Catalog=Estate; User ID=blek; Password=banderas");
SqlDataAdapter dad = new SqlDataAdapter ("SELECT blek.TypeOffer.OfferID,
blek.TypeOffer.TypeOffer FROM blek.TypeOffer", conn);

DataTable table=new DataTable();
conn.Open();
dad.Fill(table);
conn.Close();
DropDownList2.DataSource=table;
DropDownList2.DataValueField = "OfferID";
DropDownList2.DataTextField = "TypeOffer";
DropDownList2.DataBind ();
msg.Text = table.Rows.Count.ToString();
}

--
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.
DropDownList2.DataSource=table;

try: DropDownList2.DataSource=table.DefaultView;

"Viktor Popov" <viketo@.yahoo.com> wrote in message
news:uAGYoqKdEHA.1692@.tk2msftngp13.phx.gbl...
> It doesn't work...I'm stucked....
> My last code is this. When I RUN it there are no errors but the
DropDownList
> is not populated and the msg.Text=""
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> SqlConnection conn = new SqlConnection("Data Source=BLEK;Initial
> Catalog=Estate; User ID=blek; Password=banderas");
> SqlDataAdapter dad = new SqlDataAdapter ("SELECT
blek.TypeOffer.OfferID,
> blek.TypeOffer.TypeOffer FROM blek.TypeOffer", conn);
>
> DataTable table=new DataTable();
> conn.Open();
> dad.Fill(table);
> conn.Close();
> DropDownList2.DataSource=table;
> DropDownList2.DataValueField = "OfferID";
> DropDownList2.DataTextField = "TypeOffer";
> DropDownList2.DataBind ();
> msg.Text = table.Rows.Count.ToString();
> }
>
> --
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.729 / Virus Database: 484 - Release Date: 27.7.2004 a.

populate public property from a function

I have a public property in my server control and I want to populate it with
values generated by the control.
When I assign the value of the property to a function in the control, which
creates the values, I get a compilation error that says
the function doesn't have all the other property values to work with.
So, how do I populate the arraylist as a public property, so I can use it in
my web page ?
========== code in use ==========
I create the property wth the webpage by:
............
Dim arrTempList As New ArrayList()
oThis.myArrayList = arrTempList
...........
I have the the property defined in the control as:
...............
Public arrChartList As Arraylist
Public Property myArrayList As ArrayList
Get
Return arrChartList
End Get
Set
arrChartList = myfunction() '<--builds values for arraylist
End Set
End Property
.................Where is 'myfunction' declared? This looks like a scoping issue.
I am also why in the Set for a property, you would completely
ignore the argument and just call a function. Why bother having a Set on the
property to begin with? People are going to be setting the property to
something - but that something will be complete ignored? Very confusing.
"Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>I have a public property in my server control and I want to populate it
>with values generated by the control.
> When I assign the value of the property to a function in the control,
> which creates the values, I get a compilation error that says the function
> doesn't have all the other property values to work with.
> So, how do I populate the arraylist as a public property, so I can use it
> in my web page ?
>
> ========== code in use ==========
> I create the property wth the webpage by:
> ............
> Dim arrTempList As New ArrayList()
> oThis.myArrayList = arrTempList
> ...........
>
> I have the the property defined in the control as:
> ...............
> Public arrChartList As Arraylist
> Public Property myArrayList As ArrayList
> Get
> Return arrChartList
> End Get
> Set
> arrChartList = myfunction() '<--builds values for arraylist
> End Set
> End Property
> .................
>
>
"myfunction" is in the control.
Yes, I am totally on this and really need help.
what should I be doing ?
"Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:%236og2UHSGHA.4440@.TK2MSFTNGP11.
phx.gbl...
> Where is 'myfunction' declared? This looks like a scoping issue.
> I am also why in the Set for a property, you would completely ign
ore the argument and just call a function. Why bother
> having a Set on the property to begin with? People are going to be setting
the property to something - but that something will be
> complete ignored? Very confusing.
> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:
evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>
That depends on what you are trying to do in the first place. You either
want the user to assign a value to the property or you don't and want to
assign the variable a value returned by a function instead.
"Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
news:%23jldn$HSGHA.224@.TK2MSFTNGP10.phx.gbl...
> "myfunction" is in the control.
> Yes, I am totally on this and really need help.
> what should I be doing ?
>
>
> "Marina Levit [MVP]" <someone@.nospam.com> wrote in message
> news:%236og2UHSGHA.4440@.TK2MSFTNGP11.phx.gbl...
>
I want the property to have the value created by the function.
"Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:uW8uI$PSGHA.1780@.TK2MSFTNGP12.ph
x.gbl...
> That depends on what you are trying to do in the first place. You either w
ant the user to assign a value to the property or you
> don't and want to assign the variable a value returned by a function inste
ad.
> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:
%23jldn$HSGHA.224@.TK2MSFTNGP10.phx.gbl...
>

populate public property from a function

I have a public property in my server control and I want to populate it with values generated by the control.

When I assign the value of the property to a function in the control, which creates the values, I get a compilation error that says
the function doesn't have all the other property values to work with.

So, how do I populate the arraylist as a public property, so I can use it in my web page ?

========== code in use ==========
I create the property wth the webpage by:

............
Dim arrTempList As New ArrayList()
oThis.myArrayList = arrTempList
............

I have the the property defined in the control as:

................
Public arrChartList As Arraylist
Public Property myArrayList As ArrayList
Get
Return arrChartList
End Get
Set
arrChartList = myfunction() '<--builds values for arraylist
End Set
End Property
..................Where is 'myfunction' declared? This looks like a scoping issue.

I am also confused why in the Set for a property, you would completely
ignore the argument and just call a function. Why bother having a Set on the
property to begin with? People are going to be setting the property to
something - but that something will be complete ignored? Very confusing.

"Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>I have a public property in my server control and I want to populate it
>with values generated by the control.
> When I assign the value of the property to a function in the control,
> which creates the values, I get a compilation error that says the function
> doesn't have all the other property values to work with.
> So, how do I populate the arraylist as a public property, so I can use it
> in my web page ?
>
> ========== code in use ==========
> I create the property wth the webpage by:
> ............
> Dim arrTempList As New ArrayList()
> oThis.myArrayList = arrTempList
> ...........
>
> I have the the property defined in the control as:
> ...............
> Public arrChartList As Arraylist
> Public Property myArrayList As ArrayList
> Get
> Return arrChartList
> End Get
> Set
> arrChartList = myfunction() '<--builds values for arraylist
> End Set
> End Property
> .................
"myfunction" is in the control.

Yes, I am totally confused on this and really need help.

what should I be doing ?

"Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:%236og2UHSGHA.4440@.TK2MSFTNGP11.phx.gbl...
> Where is 'myfunction' declared? This looks like a scoping issue.
> I am also confused why in the Set for a property, you would completely ignore the argument and just call a function. Why bother
> having a Set on the property to begin with? People are going to be setting the property to something - but that something will be
> complete ignored? Very confusing.
> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>>I have a public property in my server control and I want to populate it with values generated by the control.
>>
>> When I assign the value of the property to a function in the control, which creates the values, I get a compilation error that
>> says the function doesn't have all the other property values to work with.
>>
>> So, how do I populate the arraylist as a public property, so I can use it in my web page ?
>>
>>
>> ========== code in use ==========
>> I create the property wth the webpage by:
>>
>> ............
>> Dim arrTempList As New ArrayList()
>> oThis.myArrayList = arrTempList
>> ...........
>>
>>
>> I have the the property defined in the control as:
>>
>> ...............
>> Public arrChartList As Arraylist
>> Public Property myArrayList As ArrayList
>> Get
>> Return arrChartList
>> End Get
>> Set
>> arrChartList = myfunction() '<--builds values for arraylist
>> End Set
>> End Property
>> .................
>>
>>
>>
That depends on what you are trying to do in the first place. You either
want the user to assign a value to the property or you don't and want to
assign the variable a value returned by a function instead.

"Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
news:%23jldn$HSGHA.224@.TK2MSFTNGP10.phx.gbl...
> "myfunction" is in the control.
> Yes, I am totally confused on this and really need help.
> what should I be doing ?
>
>
> "Marina Levit [MVP]" <someone@.nospam.com> wrote in message
> news:%236og2UHSGHA.4440@.TK2MSFTNGP11.phx.gbl...
>> Where is 'myfunction' declared? This looks like a scoping issue.
>>
>> I am also confused why in the Set for a property, you would completely
>> ignore the argument and just call a function. Why bother having a Set on
>> the property to begin with? People are going to be setting the property
>> to something - but that something will be complete ignored? Very
>> confusing.
>>
>> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message
>> news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>>>I have a public property in my server control and I want to populate it
>>>with values generated by the control.
>>>
>>> When I assign the value of the property to a function in the control,
>>> which creates the values, I get a compilation error that says the
>>> function doesn't have all the other property values to work with.
>>>
>>> So, how do I populate the arraylist as a public property, so I can use
>>> it in my web page ?
>>>
>>>
>>> ========== code in use ==========
>>> I create the property wth the webpage by:
>>>
>>> ............
>>> Dim arrTempList As New ArrayList()
>>> oThis.myArrayList = arrTempList
>>> ...........
>>>
>>>
>>> I have the the property defined in the control as:
>>>
>>> ...............
>>> Public arrChartList As Arraylist
>>> Public Property myArrayList As ArrayList
>>> Get
>>> Return arrChartList
>>> End Get
>>> Set
>>> arrChartList = myfunction() '<--builds values for
>>> arraylist
>>> End Set
>>> End Property
>>> .................
>>>
>>>
>>>
>>
>>
I want the property to have the value created by the function.

"Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:uW8uI$PSGHA.1780@.TK2MSFTNGP12.phx.gbl...
> That depends on what you are trying to do in the first place. You either want the user to assign a value to the property or you
> don't and want to assign the variable a value returned by a function instead.
> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:%23jldn$HSGHA.224@.TK2MSFTNGP10.phx.gbl...
>> "myfunction" is in the control.
>>
>> Yes, I am totally confused on this and really need help.
>>
>> what should I be doing ?
>>
>>
>>
>>
>>
>> "Marina Levit [MVP]" <someone@.nospam.com> wrote in message news:%236og2UHSGHA.4440@.TK2MSFTNGP11.phx.gbl...
>>> Where is 'myfunction' declared? This looks like a scoping issue.
>>>
>>> I am also confused why in the Set for a property, you would completely ignore the argument and just call a function. Why bother
>>> having a Set on the property to begin with? People are going to be setting the property to something - but that something will
>>> be complete ignored? Very confusing.
>>>
>>> "Jon Paal" <Jon[ nospam ]Paal @. everywhere dot com> wrote in message news:evc1ARHSGHA.5908@.TK2MSFTNGP10.phx.gbl...
>>>>I have a public property in my server control and I want to populate it with values generated by the control.
>>>>
>>>> When I assign the value of the property to a function in the control, which creates the values, I get a compilation error that
>>>> says the function doesn't have all the other property values to work with.
>>>>
>>>> So, how do I populate the arraylist as a public property, so I can use it in my web page ?
>>>>
>>>>
>>>> ========== code in use ==========
>>>> I create the property wth the webpage by:
>>>>
>>>> ............
>>>> Dim arrTempList As New ArrayList()
>>>> oThis.myArrayList = arrTempList
>>>> ...........
>>>>
>>>>
>>>> I have the the property defined in the control as:
>>>>
>>>> ...............
>>>> Public arrChartList As Arraylist
>>>> Public Property myArrayList As ArrayList
>>>> Get
>>>> Return arrChartList
>>>> End Get
>>>> Set
>>>> arrChartList = myfunction() '<--builds values for arraylist
>>>> End Set
>>>> End Property
>>>> .................
>>>>
>>>>
>>>>
>>>
>>>
>>
>>

Friday, March 16, 2012

Populating drop down list from database AND manually

I have a drop down list which ive popukated from my SQL Server database. However, I want to manually add another item to the list, as it doesnt appear in my DB query.

How do I do this ??

thanks
ferkh10You can use the "insert()" methods of the item array in the drop down list.

If you want to place it after all your values, just do "Insert()".

example:

dropdown.Items.Insert(new ListItem("Text", "value"))

If you want to place it in a particular place, do

dropdown.Items.Insert(IndexToPutItem, new ListItem("Text", "value"))

Note that code is in C#

Hope this helps,
Covo
ddl.Items.Insert(0,New ListItem("text","value"))
My DDL is created in an EditItemTemplate, and I dont seem to be able to reference it from my code behind. Heres where i created the DDL :


<EditItemTemplate>
<asp:DropDownList runat="server" id="ddlAccountNames" DataValueField="intMTIID" DataTextField="vchAccount" DataSource='<%# GetAccountNames() %>' SelectedIndex='<%# GetSelectedIndex(Container.DataItem("intMTIID")) %>' >
</asp:DropDownList>
</EditItemTemplate>

I populate the DDL using the code below :


Function GetAccountNames() As DataSet
'Populate the ddlDataSet

Const strConnStr As String = "XXXXXXXXXXXX"
Dim myConnection As New Data.SqlClient.SqlConnection(strConnStr)

Const strSQL = "spGetMarketTraderAccounts "
Dim myDataAdapter As Data.SqlClient.SqlDataAdapter = New Data.SqlClient.SqlDataAdapter(strSQL, myConnection)
myDataAdapter.Fill(ddlDataSet, "Accounts")

Return ddlDataSet
End Function

Whereabouts do I need to put the InsertAt statement ? Ive tried putting it into the GetAccountNames function, but its not recognising the DDL name.
If it is in edit item you can reference it in codebehind from DataGrid's ItemDataBound event handler (you get the correct item by checking when item is of type EditItem, from event handler's event arguments)
Im still having real problems with this. Can anybody post a code example that I can use ??

thanks.
Your grid could be like this:


<asp:DataGrid ID="ExampleGrid" Runat="server" AutoGenerateColumns="False">
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" EditText="Edit" CancelText="Cancel" />
<asp:TemplateColumn>
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem,"SelectedField")%>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat="server" id="ddlAccountNames" />
</EditItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField="SomeText" ReadOnly="True" />
</Columns>
</asp:DataGrid>

Then the code:


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not Page.IsPostBack Then
'Bind DataGrid to dummy data
Bindgrid()
End If
End Sub

'Bind the grid itself using dummy data
Private Sub Bindgrid()
Dim dt As New DataTable
dt.Columns.Add("SelectedField", GetType(Integer))
dt.Columns.Add("SomeText", GetType(String))

Dim dr As DataRow = dt.NewRow()
dr(0) = 1
dr(1) = "One thing here"
dt.Rows.Add(dr)

dr = dt.NewRow()
dr(0) = 2
dr(1) = "Two things there"
dt.Rows.Add(dr)

dr = dt.NewRow()
dr(0) = 3
dr(1) = "Three things anywhere"
dt.Rows.Add(dr)

ExampleGrid.DataSource = dt
ExampleGrid.DataBind()
End Sub

Private Sub ExampleGrid_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles ExampleGrid.ItemDataBound
If e.Item.ItemType = ListItemType.EditItem Then
'LOcate the DDL in the edit item
Dim ddl As DropDownList = CType(e.Item.FindControl("ddlAccountNames"), DropDownList)
ddl.DataSource = GetAccountNames()
ddl.DataValueField = "Field"
ddl.DataTextField = "Text"
ddl.DataBind()

'Search for the item in grid's data source and put it as seleted
Dim ditem As DataRowView = CType(e.Item.DataItem, DataRowView)
ddl.SelectedIndex = ddl.Items.IndexOf(ddl.Items.FindByValue(ditem("SelectedField")))
End If
End Sub

Private Function GetAccountNames() As DataSet
'Using dummy data here for ddl populating
Dim ds As New DataSet
Dim dt As New DataTable
ds.Tables.Add(dt)
dt.Columns.Add("Field", GetType(Integer))
dt.Columns.Add("Text", GetType(String))

Dim dr As DataRow = dt.NewRow()
dr(0) = 1
dr(1) = "One"
dt.Rows.Add(dr)

dr = dt.NewRow()
dr(0) = 2
dr(1) = "Two"
dt.Rows.Add(dr)

dr = dt.NewRow()
dr(0) = 3
dr(1) = "Three"
dt.Rows.Add(dr)

Return ds
End Function

Private Sub ExampleGrid_EditCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles ExampleGrid.EditCommand
ExampleGrid.EditItemIndex = e.Item.ItemIndex
Bindgrid()
End Sub

Private Sub ExampleGrid_CancelCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles ExampleGrid.CancelCommand
ExampleGrid.EditItemIndex = -1
Bindgrid()
End Sub

This example doesn't show how to pass changes in DDL to the database, but that shouldn't be big deal either.

Populating dropdown on server side...(non database)

This is probably really simple but I have a mental block on this...
I want to populate a dropdown on the serverside thru code and am unsure of which methods or properties to use...
Its a simple dropdown. Numbered 1 to 100. So I know I have to loop thru..
Any help would be appreciated...What kind of data source you what to use to populate the DDL if not from database?
You will need to create an array, add data to that array and Bind it to your list:


Dim month as New ArrayList

'adding values for array month
With month
.Add("Jan")
.Add("Feb")
.Add("Mar")
.Add("Apr")
.Add("May")
.Add("Jun")
.Add("Jul")
.Add("Aug")
.Add("Sep")
.Add("Oct")
.Add("Nov")
.Add("Dec")
End With

'bind it to your drop down list

DDList.DataSource=month
DDList.DataBind()


Just a loop...sort of like this
I am just not sure what mehods to use...
dim x as integer
Do while x <= 100
dropdown1.add = x
x = x+1
loop
 Dim month as New ArrayList

dim x as integer

Do while x <= 100

with month
.add = x
end with

x = x+1

loop

DDList.DataSource=month

DDList.DataBind()

populating dropdownlist (asp.net server ctrl) from clientside jscr

Hello together,

I tried to find out about populating an asp.net server control (a
dropdownlist) from the clientside jscript, but I didn't find a solution up
to now.
I cannot use a html dropdownlist, because a database query in codebehind has
to be done, when a new listItem is selected. So, I need to use a
servercontrol dropdownlist.

Now to my problem:
I have two dropdownlists in use. One of them should show listItems that are
dependent on the selection of the other one. I know that I need to use the
clientside onchange() Event on the dropdownlistbox that decides what has to
be shown in the other dropdownlist, because no postback should occur for this.
The C# syntax, that is used in codebehind, doesn't work, JScript gives me an
error that the object doesn't support this method.
I can set the text and state of servercontrols like textBoxes and checkBoxes
from clientside jscript with document.Form1.TextBox1..., so it should also be
possible to do this with a dropdownlist too, shouldn't it?

I tried it with Ajax.NET, but when I called a serverside function that
should manipulate the dropdownlist, a nullpointerexception occurs, because
all the instances of the serverside controls are "undefined" (I saw it in the
debugger). I've no explanation for this, as they are created on page_Load. So
I cancelled my efforts introducing Ajax into this. As the project is nearly
finished, I would like to avoid using Ajax for the dropdownlist stuff.

I hope somebody can help

Thanks in advance

RFS666var i = document.forms[0].DropDownListName.length
document.forms[0].DropDownListName.options[i] = new Option('new text','new
value');

HTH

"RFS666" wrote:

> Hello together,
> I tried to find out about populating an asp.net server control (a
> dropdownlist) from the clientside jscript, but I didn't find a solution up
> to now.
> I cannot use a html dropdownlist, because a database query in codebehind has
> to be done, when a new listItem is selected. So, I need to use a
> servercontrol dropdownlist.
> Now to my problem:
> I have two dropdownlists in use. One of them should show listItems that are
> dependent on the selection of the other one. I know that I need to use the
> clientside onchange() Event on the dropdownlistbox that decides what has to
> be shown in the other dropdownlist, because no postback should occur for this.
> The C# syntax, that is used in codebehind, doesn't work, JScript gives me an
> error that the object doesn't support this method.
> I can set the text and state of servercontrols like textBoxes and checkBoxes
> from clientside jscript with document.Form1.TextBox1..., so it should also be
> possible to do this with a dropdownlist too, shouldn't it?
> I tried it with Ajax.NET, but when I called a serverside function that
> should manipulate the dropdownlist, a nullpointerexception occurs, because
> all the instances of the serverside controls are "undefined" (I saw it in the
> debugger). I've no explanation for this, as they are created on page_Load. So
> I cancelled my efforts introducing Ajax into this. As the project is nearly
> finished, I would like to avoid using Ajax for the dropdownlist stuff.
> I hope somebody can help
> Thanks in advance
> RFS666
First, when the browser sees the control, it is no longer a server-side
control, but just HTML. You can do whatever you can with the control, but
it needs to be through JavaScript with JS syntax and commands. Take a look
at the
http://msdn.microsoft.com/workshop/...asp?frame=true
for information about the those lists from the IE perspective.

In order for the server objects to be populated, you must to some form of
postback, otherwise the server does not know what to do. You might consider
using SmartNavigation and performing postbacks without the screen flicker.

"RFS666" <RFS666@.discussions.microsoft.com> wrote in message
news:E43B8B5B-BBBB-4C78-BCD1-E70ED60F329C@.microsoft.com...
> Hello together,
> I tried to find out about populating an asp.net server control (a
> dropdownlist) from the clientside jscript, but I didn't find a solution
> up
> to now.
> I cannot use a html dropdownlist, because a database query in codebehind
> has
> to be done, when a new listItem is selected. So, I need to use a
> servercontrol dropdownlist.
> Now to my problem:
> I have two dropdownlists in use. One of them should show listItems that
> are
> dependent on the selection of the other one. I know that I need to use the
> clientside onchange() Event on the dropdownlistbox that decides what has
> to
> be shown in the other dropdownlist, because no postback should occur for
> this.
> The C# syntax, that is used in codebehind, doesn't work, JScript gives me
> an
> error that the object doesn't support this method.
> I can set the text and state of servercontrols like textBoxes and
> checkBoxes
> from clientside jscript with document.Form1.TextBox1..., so it should also
> be
> possible to do this with a dropdownlist too, shouldn't it?
> I tried it with Ajax.NET, but when I called a serverside function that
> should manipulate the dropdownlist, a nullpointerexception occurs, because
> all the instances of the serverside controls are "undefined" (I saw it in
> the
> debugger). I've no explanation for this, as they are created on page_Load.
> So
> I cancelled my efforts introducing Ajax into this. As the project is
> nearly
> finished, I would like to avoid using Ajax for the dropdownlist stuff.
> I hope somebody can help
> Thanks in advance
> RFS666
you need to lean the browser dom to do client script (or ajax). also if you
change the entires in a list client side, you need to send this info to the
server somehow (usually a hidden field), as the browser only posts pack the
selected value of a dropdown. you shoudl go to the bookstore and pickup a
book on javascript.

-- bruce (sqlwork.com)

"RFS666" <RFS666@.discussions.microsoft.com> wrote in message
news:E43B8B5B-BBBB-4C78-BCD1-E70ED60F329C@.microsoft.com...
> Hello together,
> I tried to find out about populating an asp.net server control (a
> dropdownlist) from the clientside jscript, but I didn't find a solution
> up
> to now.
> I cannot use a html dropdownlist, because a database query in codebehind
> has
> to be done, when a new listItem is selected. So, I need to use a
> servercontrol dropdownlist.
> Now to my problem:
> I have two dropdownlists in use. One of them should show listItems that
> are
> dependent on the selection of the other one. I know that I need to use the
> clientside onchange() Event on the dropdownlistbox that decides what has
> to
> be shown in the other dropdownlist, because no postback should occur for
> this.
> The C# syntax, that is used in codebehind, doesn't work, JScript gives me
> an
> error that the object doesn't support this method.
> I can set the text and state of servercontrols like textBoxes and
> checkBoxes
> from clientside jscript with document.Form1.TextBox1..., so it should also
> be
> possible to do this with a dropdownlist too, shouldn't it?
> I tried it with Ajax.NET, but when I called a serverside function that
> should manipulate the dropdownlist, a nullpointerexception occurs, because
> all the instances of the serverside controls are "undefined" (I saw it in
> the
> debugger). I've no explanation for this, as they are created on page_Load.
> So
> I cancelled my efforts introducing Ajax into this. As the project is
> nearly
> finished, I would like to avoid using Ajax for the dropdownlist stuff.
> I hope somebody can help
> Thanks in advance
> RFS666

populating dropdownlist (asp.net server ctrl) from clientside jscr

Hello together,
I tried to find out about populating an asp.net server control (a
dropdownlist) from the clientside jscript, but I didn't find a solution up
to now.
I cannot use a html dropdownlist, because a database query in codebehind has
to be done, when a new listItem is selected. So, I need to use a
servercontrol dropdownlist.
Now to my problem:
I have two dropdownlists in use. One of them should show listItems that are
dependent on the selection of the other one. I know that I need to use the
clientside onchange() Event on the dropdownlistbox that decides what has to
be shown in the other dropdownlist, because no postback should occur for thi
s.
The C# syntax, that is used in codebehind, doesn't work, JScript gives me an
error that the object doesn't support this method.
I can set the text and state of servercontrols like textBoxes and checkBoxes
from clientside jscript with document.Form1.TextBox1..., so it should also b
e
possible to do this with a dropdownlist too, shouldn't it?
I tried it with Ajax.NET, but when I called a serverside function that
should manipulate the dropdownlist, a nullpointerexception occurs, because
all the instances of the serverside controls are "undefined" (I saw it in th
e
debugger). I've no explanation for this, as they are created on page_Load. S
o
I cancelled my efforts introducing Ajax into this. As the project is nearly
finished, I would like to avoid using Ajax for the dropdownlist stuff.
I hope somebody can help
Thanks in advance
RFS666var i = document.forms[0].DropDownListName.length
document.forms[0].DropDownListName.options[i] = new Option('new text','new
value');
HTH
"RFS666" wrote:

> Hello together,
> I tried to find out about populating an asp.net server control (a
> dropdownlist) from the clientside jscript, but I didn't find a solution u
p
> to now.
> I cannot use a html dropdownlist, because a database query in codebehind h
as
> to be done, when a new listItem is selected. So, I need to use a
> servercontrol dropdownlist.
> Now to my problem:
> I have two dropdownlists in use. One of them should show listItems that ar
e
> dependent on the selection of the other one. I know that I need to use the
> clientside onchange() Event on the dropdownlistbox that decides what has t
o
> be shown in the other dropdownlist, because no postback should occur for t
his.
> The C# syntax, that is used in codebehind, doesn't work, JScript gives me
an
> error that the object doesn't support this method.
> I can set the text and state of servercontrols like textBoxes and checkBox
es
> from clientside jscript with document.Form1.TextBox1..., so it should also
be
> possible to do this with a dropdownlist too, shouldn't it?
> I tried it with Ajax.NET, but when I called a serverside function that
> should manipulate the dropdownlist, a nullpointerexception occurs, because
> all the instances of the serverside controls are "undefined" (I saw it in
the
> debugger). I've no explanation for this, as they are created on page_Load.
So
> I cancelled my efforts introducing Ajax into this. As the project is nearl
y
> finished, I would like to avoid using Ajax for the dropdownlist stuff.
> I hope somebody can help
> Thanks in advance
> RFS666
First, when the browser sees the control, it is no longer a server-side
control, but just HTML. You can do whatever you can with the control, but
it needs to be through JavaScript with JS syntax and commands. Take a look
at the
http://msdn.microsoft.com/workshop/...me
=true
for information about the those lists from the IE perspective.
In order for the server objects to be populated, you must to some form of
postback, otherwise the server does not know what to do. You might consider
using SmartNavigation and performing postbacks without the screen flicker.
"RFS666" <RFS666@.discussions.microsoft.com> wrote in message
news:E43B8B5B-BBBB-4C78-BCD1-E70ED60F329C@.microsoft.com...
> Hello together,
> I tried to find out about populating an asp.net server control (a
> dropdownlist) from the clientside jscript, but I didn't find a solution
> up
> to now.
> I cannot use a html dropdownlist, because a database query in codebehind
> has
> to be done, when a new listItem is selected. So, I need to use a
> servercontrol dropdownlist.
> Now to my problem:
> I have two dropdownlists in use. One of them should show listItems that
> are
> dependent on the selection of the other one. I know that I need to use the
> clientside onchange() Event on the dropdownlistbox that decides what has
> to
> be shown in the other dropdownlist, because no postback should occur for
> this.
> The C# syntax, that is used in codebehind, doesn't work, JScript gives me
> an
> error that the object doesn't support this method.
> I can set the text and state of servercontrols like textBoxes and
> checkBoxes
> from clientside jscript with document.Form1.TextBox1..., so it should also
> be
> possible to do this with a dropdownlist too, shouldn't it?
> I tried it with Ajax.NET, but when I called a serverside function that
> should manipulate the dropdownlist, a nullpointerexception occurs, because
> all the instances of the serverside controls are "undefined" (I saw it in
> the
> debugger). I've no explanation for this, as they are created on page_Load.
> So
> I cancelled my efforts introducing Ajax into this. As the project is
> nearly
> finished, I would like to avoid using Ajax for the dropdownlist stuff.
> I hope somebody can help
> Thanks in advance
> RFS666
you need to lean the browser dom to do client script (or ajax). also if you
change the entires in a list client side, you need to send this info to the
server somehow (usually a hidden field), as the browser only posts pack the
selected value of a dropdown. you shoudl go to the bookstore and pickup a
book on javascript.
-- bruce (sqlwork.com)
"RFS666" <RFS666@.discussions.microsoft.com> wrote in message
news:E43B8B5B-BBBB-4C78-BCD1-E70ED60F329C@.microsoft.com...
> Hello together,
> I tried to find out about populating an asp.net server control (a
> dropdownlist) from the clientside jscript, but I didn't find a solution
> up
> to now.
> I cannot use a html dropdownlist, because a database query in codebehind
> has
> to be done, when a new listItem is selected. So, I need to use a
> servercontrol dropdownlist.
> Now to my problem:
> I have two dropdownlists in use. One of them should show listItems that
> are
> dependent on the selection of the other one. I know that I need to use the
> clientside onchange() Event on the dropdownlistbox that decides what has
> to
> be shown in the other dropdownlist, because no postback should occur for
> this.
> The C# syntax, that is used in codebehind, doesn't work, JScript gives me
> an
> error that the object doesn't support this method.
> I can set the text and state of servercontrols like textBoxes and
> checkBoxes
> from clientside jscript with document.Form1.TextBox1..., so it should also
> be
> possible to do this with a dropdownlist too, shouldn't it?
> I tried it with Ajax.NET, but when I called a serverside function that
> should manipulate the dropdownlist, a nullpointerexception occurs, because
> all the instances of the serverside controls are "undefined" (I saw it in
> the
> debugger). I've no explanation for this, as they are created on page_Load.
> So
> I cancelled my efforts introducing Ajax into this. As the project is
> nearly
> finished, I would like to avoid using Ajax for the dropdownlist stuff.
> I hope somebody can help
> Thanks in advance
> RFS666