hi viewers,
am vivega,i need info abt drop down list(ddl).could u plz tel me how to display date-month-year in ddl using asp.net?it's very imp n urgent.

aspx

<asp:DropDownList id="ddl1"  runat="server" >    </asp:DropDownList>

Code behind

ddl1.Items.Add(Format(Date.Today, "dd MMM yyyy"))

Mark as fixed if it helps you!!!

thnx for ur reply n sorry bcoz am a fresher so i could not able to get u.could u plz tell me what it means?and my doubt is, does it generate d-m-y automatically? plz tel me any website or link related to this concept if poss. it's very imp n urgent sir.

thanks in advance,
============================================

aspx

<asp:DropDownList id="ddl1"  runat="server" >    </asp:DropDownList>

Code behind

ddl1.Items.Add(Format(Date.Today, "dd MMM yyyy"))

Mark as fixed if it helps you!!!

if u mean explaination: then

First add an .aspx page then drag n drop ddl on page and set its property to autopostback = true. then

from design page double click the ddl its takes u to the code behind page where u will be coding. just find the Page_load event to add the
ddl1.Items.Add(Format(Date.Today, "dd MMM yyyy"))

sir,i did as u told but am getting 3 errors,those are:

Error 1 The name 'ddl1' does not exist in the current context
Error 2 The name 'Format' does not exist in the current context
Error 3 The name 'Date' does not exist in the current context

if u mean explaination: then

First add an .aspx page then drag n drop ddl on page and set its property to autopostback = true. then

from design page double click the ddl its takes u to the code behind page where u will be coding. just find the Page_load event to add the
ddl1.Items.Add(Format(Date.Today, "dd MMM yyyy"))

pls, c the code below

aspx page

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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:TextBox ID="TextBox1" runat="server"></asp:TextBox>
     <asp:DropDownList id="ddl1"  runat="server" AutoPostBack="True"  >    </asp:DropDownList>
    </div>
    </form>
</body>
</html>

code behind

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ddl1.Items.Add(Format(Date.Today, "dd MMM yyyy"))
    End Sub

    Protected Sub ddl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl1.SelectedIndexChanged
        TextBox1.Text = ddl1.SelectedItem.Value

    End Sub
End Class

sir,thnx n i got output. But i wanted to display not the present date but i wanted d-m-y like calender.means,whatever the d-m-y we wanted,it will get selected by the user from drop down list. It may be today's date or previous or coming date I think i explained well.one more thing is i know only C#. u answered very patiently. i dont want to disturb u more.thnx.

pls, c the code below

aspx page

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!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:TextBox ID="TextBox1" runat="server"></asp:TextBox>
     <asp:DropDownList id="ddl1"  runat="server" AutoPostBack="True"  >    </asp:DropDownList>
    </div>
    </form>
</body>
</html>

code behind

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        ddl1.Items.Add(Format(Date.Today, "dd MMM yyyy"))
    End Sub

    Protected Sub ddl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddl1.SelectedIndexChanged
        TextBox1.Text = ddl1.SelectedItem.Value

    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.