DropDownList

Discussion in 'ASP .Net' started by Eugene Anthony, Feb 4, 2007.

  1. ModifyUserRegistration.aspx
    ---------------------------


    <%@ Page Language="C#" AutoEventWireup="true"
    CodeFile="ModifyUserRegistration.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">

    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head id="Head1" runat="server">
    <title>Untitled Page</title>
    </head>
    <body>
    <br /><br />
    <form id="form1" runat="server">
    <asp:Repeater ID="rptItems" runat="server"
    OnItemCommand="rptItems_ItemCommand">
    <HeaderTemplate>
    <table border="0" width="304">
    </HeaderTemplate>
    <ItemTemplate>
    <tr>
    <td width="294" colspan="2" bgcolor="#FFCC99">
    <p align="center"><b>Modify User Registration</b></p>
    </td>
    </tr>
    <tr>
    <td colspan="2">
    </td>
    </tr>
    <tr>
    <td style="width: 100px"><asp:Label ID="Label1" runat="server"
    Text="Email"></asp:Label></td>
    <td style="width: 205px"><%# Eval("Email") %></td>
    </tr>
    <tr>
    <td style="width: 100px"><asp:Label ID="Label2" runat="server"
    Text="Password"></asp:Label></td>
    <td style="width: 205px"><%# Eval("Password") %></td>
    </tr>
    <tr>
    <td style="width: 100px"><asp:Label ID="Label3" runat="server"
    Text="FirstName"></asp:Label></td>
    <td style="width: 205px"><%# Eval("FirstName") %></td>
    </tr>
    <tr>
    <td style="width: 100px"><asp:Label ID="Label4" runat="server"
    Text="LastName"></asp:Label></td>
    <td style="width: 205px"><%# Eval("LastName") %></td>
    </tr>
    <tr>
    <td style="width: 100px"><asp:Label ID="Label5" runat="server"
    Text="Country"></asp:Label></td>
    <td style="width: 205px"><%# Eval("Country") %></td>
    </tr>
    <tr>
    <td style="width: 100px"><asp:Label ID="Label6" runat="server"
    Text="PostalCode"></asp:Label></td>
    <td style="width: 205px"><%# Eval("PostalCode") %></td>
    </tr>
    <tr>
    <td style="width: 100px"><asp:Label ID="Label7" runat="server"
    Text="Gender"></asp:Label></td>
    <td style="width: 205px"><%# Eval("Gender") %></td>
    </tr>
    <tr>
    <td style="width: 100px"><asp:Label ID="Label8" runat="server"
    Text="DOB"></asp:Label></td>
    <td style="width: 205px"><%# Eval("DOB") %></td>
    </tr>
    <tr>
    <td style="width: 100px"><asp:Label ID="Label9" runat="server"
    Text="Status"></asp:Label></td>
    <td style="width: 205px"><aspropDownList ID="DropDownList1"
    runat="server"></aspropDownList></td>
    </tr>
    <tr>
    <td style="width: 100px"></td>
    <td style="width: 205px">
    </td>
    </tr>
    <tr>
    <td style="width: 100px"></td>
    <td style="width: 205px">
    <asp:Button ID="Button1" runat="server" Text="Modify"
    OnClick="Button1_Click" />
    </td>
    </tr>
    <tr>
    <td style="width: 100px">
    </td>
    <td style="width: 205px; text-align: right;">
    </td>
    </tr>
    </ItemTemplate>
    <FooterTemplate>
    </table>
    </FooterTemplate>
    </asp:Repeater>
    </form>
    </body>

    </html>






    ModifyUserRegistration.aspx.cs
    ------------------------------


    using System;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;

    public partial class _Default : System.Web.UI.Page
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    String[] status = { "Enabled", "Disabled" };
    DropDownList1.DataSource = status;
    DropDownList1.DataBind();


    if (!Page.IsPostBack)
    LoadData();
    }

    private void LoadData()
    {
    String videoID = Request.QueryString["VideoID"];
    SqlConnection cnn = new
    SqlConnection(ConfigurationManager.ConnectionStrings["myConnection"].Con
    nectionString);
    SqlCommand myCommand = new SqlCommand();
    myCommand.Connection = cnn;
    myCommand.CommandText = "SELECT * FROM Authentication WHERE
    AuthenticationID=1";
    myCommand.CommandType = CommandType.Text;
    SqlDataAdapter myAdapter = new SqlDataAdapter(myCommand);
    DataSet ds = new DataSet();
    myAdapter.Fill(ds, "Authentication");

    rptItems.DataSource = ds;
    rptItems.DataBind();
    }
    protected void rptItems_ItemCommand(object source,
    RepeaterCommandEventArgs e)
    {
    LoadData();
    }

    protected void Button1_Click(object sender, EventArgs e)
    {

    }
    }



    I attempted to specify the code bellow:


    String[] status = { "Enabled", "Disabled" };
    DropDownList1.DataSource = status;
    DropDownList1.DataBind();


    In my Page_Load function and I got an error saying:


    Error 1 The name 'DropDownList1' does not exist in the current context
    C:\Documents and Settings\solomon\My Documents\Visual Studio
    2005\WebSites\WebSite4\ModifyUserRegistration.aspx.cs 17 9
    C:\...\WebSite4\


    How do I solve the problem?.


    Your help is kindly appreciated.


    Eugene Anthony

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Eugene Anthony, Feb 4, 2007
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. mr2_93
    Replies:
    1
    Views:
    3,665
    mr2_93
    Oct 2, 2005
  2. tshad
    Replies:
    8
    Views:
    2,260
    tshad
    Oct 19, 2005
  3. =?Utf-8?B?SnVhbmpv?=

    GridView: Filtr DropDownList from another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 23, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,897
    =?Utf-8?B?SnVhbmpv?=
    Dec 23, 2005
  4. =?Utf-8?B?SnVhbmpv?=

    GridView: Filter DropDownList for another DropDownList

    =?Utf-8?B?SnVhbmpv?=, Dec 29, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    1,336
    =?Utf-8?B?SnVhbmpv?=
    Dec 29, 2005
  5. keithb
    Replies:
    1
    Views:
    12,166
    shauns1
    Nov 1, 2006
Loading...

Share This Page