Drop down list problem

Last post 09-14-2009 9:53 AM by vishal bhatt. 4 replies.

Sort Posts:

  • Drop down list problem

    08-01-2009, 8:59 AM
    • Member
      3 point Member
    • ronaldcklok
    • Member since 08-01-2009, 12:45 PM
    • Posts 3

     Help!.......

    I've written a program using VWD 2008, I wrote one drop down list and try to update to the access database but getting an error. I don't know what wrong with my program. Any one could help me. I'm really frastrated with this step.

    Here below is my progarm......Please

    Thank you very much

     

    <%@ Page Title=""
    Language="C#" MasterPageFile="~/MasterPage.master"
    AutoEventWireup="true"
    CodeFile="Default.aspx.cs"
    CodeBehind="~/Default.aspx.cs"
    Inherits="_Default" %>

    <script runat="server">

      void ItemInserted(object obj, FormViewInsertedEventArgs e) { FormView1.DataBind(); }
      void ItemUpdated(object obj, FormViewUpdatedEventArgs e) { FormView1.DataBind(); }
      void ItemDeleted(object obj, FormViewDeletedEventArgs e) { FormView1.DataBind(); }

      void FormViewInserting(object obj, FormViewInsertEventArgs e)
      // P.7-26 王有禮
      {
        TextBox CompanyName = (TextBox)FormView1.FindControl("tbxCompanyName2");
        TextBox ContactName = (TextBox)FormView1.FindControl("tbxContactName2");
        TextBox Title = (TextBox)FormView1.FindControl("tbxTitle2");
        TextBox Address = (TextBox)FormView1.FindControl("tbxAddress2");
        TextBox TelNo1 = (TextBox)FormView1.FindControl("tbxTelNo12");
        TextBox TelNo2 = (TextBox)FormView1.FindControl("tbxTelNo22");
        TextBox FaxNo = (TextBox)FormView1.FindControl("tbxFaxNo2");
        TextBox Mobile = (TextBox)FormView1.FindControl("tbxMobile2");
        TextBox Email = (TextBox)FormView1.FindControl("tbxEmail2");
        TextBox WebSite = (TextBox)FormView1.FindControl("tbxWebSite2");

        e.Values["CompanyName"] = CompanyName.Text;
        e.Values["ContactName"] = ContactName.Text;
        e.Values["Title"] = Title.Text;
        e.Values["Address"] = Address.Text;
        e.Values["TelNo1"] = TelNo1.Text;
        e.Values["TelNo2"] = TelNo2.Text;
        e.Values["FaxNo"] = FaxNo.Text;
        e.Values["Mobile"] = Mobile.Text;
        e.Values["Email"] = Email.Text;
        e.Values["WebSite"] = WebSite.Text;
      }
     
      void FormViewUpdating(object obj, FormViewUpdateEventArgs e)
       // P.7-26 王有禮
      
      {
        TextBox CompanyName = (TextBox)FormView1.FindControl("tbxCompanyName");
        TextBox ContactName = (TextBox)FormView1.FindControl("tbxContactName");
        TextBox Title = (TextBox)FormView1.FindControl("tbxTitle");
        TextBox Address = (TextBox)FormView1.FindControl("tbxAddress");
        TextBox TelNo1 = (TextBox)FormView1.FindControl("tbxTelNo1");
        TextBox TelNo2 = (TextBox)FormView1.FindControl("tbxTelNo2");
        TextBox FaxNo = (TextBox)FormView1.FindControl("tbxFaxNo");
        TextBox Mobile = (TextBox)FormView1.FindControl("tbxMobile");
        TextBox Email = (TextBox)FormView1.FindControl("tbxEmail");
        TextBox WebSite = (TextBox)FormView1.FindControl("tbxWebSite");
        CheckBox Print = (CheckBox)FormView1.FindControl("ckbPrint");
        // TextBox EmployeeNo = (TextBox)FormView1.FindControl("tbxEmployeeNo");
        DropDownList EmployeeNo = (DropDownList)FormView1.FindControl("emp");
             
        e.NewValues["CompanyName"] = CompanyName.Text;
        e.NewValues["ContactName"] = ContactName.Text;
        e.NewValues["Title"] = Title.Text;
        e.NewValues["Address"] = Address.Text;
        e.NewValues["TelNo1"] = TelNo1.Text;
        e.NewValues["TelNo2"] = TelNo2.Text;
        e.NewValues["FaxNo"] = FaxNo.Text;
        e.NewValues["Mobile"] = Mobile.Text;
        e.NewValues["Email"] = Email.Text;
        e.NewValues["WebSite"] = WebSite.Text;
        e.NewValues["Print"] = Print.Checked;
        // e.NewValues["EmployeeNo"] = Convert.ToInt16(EmployeeNo.Text);
        e.NewValues["EmployeeNo"] = Convert.ToInt16(emp.DataValueField);
        
      }

    </script>


    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    &nbsp; &nbsp;&nbsp;

    <asp:Label ID="Label1" runat="server" Text="Label" Font-Size="8pt" ForeColor="White" style="z-index: 1; left: 880px; top: 53px; position: absolute"></asp:Label>

    <!--// ***************************   AccessDataSource 1 *********************************** //-->
     
     
     
       
     
     
      <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/FATTAT.db1.mdb"
        SelectCommand="SELECT [CustomerNo], [ContactName], [Title], [CompanyName], [Address], [TelNo1], [TelNo2] FROM
                                     [tblCustomer] WHERE ([CompanyName] LIKE '%' + ? + '%')">
        <SelectParameters>
            <asp:ControlParameter ControlID="tbSearch" Name="CompanyName" PropertyName="Text" Type="String" />
        </SelectParameters>
    </asp:AccessDataSource>

    <!--// ***************************   TextBox for Input search data *********************************** //-->
    <asp:TextBox ID="tbSearch" runat="server" style="z-index: 1; left: 820px; top: 26px; position: absolute" AutoPostBack="True"></asp:TextBox>

    <!--// ***************************   Label for prompting *********************************** //-->
    <asp:Label ID="Label2" runat="server" Font-Bold="True" ForeColor="White" style="z-index: 101; left: 654px; top: 29px; position: absolute"
      Text="Please Input Company Name :" Font-Size="8pt"></asp:Label>

    <!--// ***************************   AccessDataSource 2 *********************************** //-->
       
    <asp:AccessDataSource ID="AccessDataSource2" runat="server"
        DataFile="~/App_Data/FATTAT.db1.mdb"
       
        SelectCommand="SELECT tblCustomer.CustomerNo, tblCustomer.CompanyName, tblCustomer.ContactName, tblCustomer.Title,
                                      tblCustomer.Address, tblCustomer.TelNo1, tblCustomer.TelNo2, tblCustomer.FaxNo, tblCustomer.Mobile,
                                      tblCustomer.Pager, tblCustomer.Email, tblCustomer.WebSite,
                                      tblCustomer.EmployeeNo, tblCustomer.LocationNo, tblCustomer.NatureCode,
                                      tblCustomer.Print, tblCustomer.CoName, tblCustomer.Attn, tblCustomer.DeliveryWeek, tblCustomer.DeliveryTime,
                                      tblCustomer.XmasCard,
                                      tblEmployee.EmployeeNo AS empEmployeeNo, tblEmployee.ChineseName,
                                      tblLocation.LocationNo, tblLocation.LocationName,
                                      tblArea.AreaCode, tblArea.AreaName
                                                                       
                                      FROM (((tblCustomer INNER JOIN tblLocation ON tblCustomer.LocationNo = tblLocation.LocationNo) INNER JOIN
                                      tblArea ON tblLocation.AreaCode = tblArea.AreaCode) INNER JOIN tblEmployee ON tblCustomer.EmployeeNo =
                                      tblEmployee.EmployeeNo) WHERE CustomerNo=@CustomerNo"
       
        UpdateCommand="UPDATE tblCustomer SET CompanyName=@CompanyName, ContactName=@ContactName, Title=@Title,
                                        Address=@Address, TelNo1=@TelNo1, TelNo2=@TelNo2, FaxNo=@FaxNo, Mobile=@Mobile,
                                        Email=@Email, WebSite=@WebSite, Print=@Print,
                                        EmployeeNo=emp
                                        WHERE CustomerNo=@CustomerNo"
       
        DeleteCommand="DELETE FROM tblCustomer WHERE CustomerNo=@CustomerNO"
       
        InsertCommand="INSERT INTO tblCustomer (CompanyName, ContactName, Title, Address, TelNo1, TelNo2, FaxNo, Mobile, Email, WebSite, EmployeeNo
                                      LocationNo, NatureCode, Print, CoName, Attn, DeliveryWeek, DeliveryTime, XmasCard)
                                      VALUES
                                      (tbxCompanyName, tbxContactName, tbxTitle, tbxAddress, tbxTelNo1, tbxTelNo2, tbxFaxNo, tbxMobile, tbxEmail, tbxWebSite
                                      tbxEmployeeNo, tbxLocationNo, tbxNatureCode, tbxPrint, tbxCoName, tbxAttn, tbxDeliveryWeek, tbxDeliveryTime, tbxX'masCard)" >
       
        <SelectParameters>
          <asp:ControlParameter ControlID="myGridView" Name="CustomerNo" PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
    </asp:AccessDataSource>

    <!--// ***************************   AccessDataSource 3 *********************************** //-->

    <asp:AccessDataSource ID="AccessDataSource3" runat="server" DataFile="~/App_Data/FATTAT.db1.mdb"
         SelectCommand="SELECT tblEmployee.EmployeeNo AS emp, tblEmployee.ChineseName FROM tblEmployee" >
         <SelectParameters>
          <asp:ControlParameter ControlID="FormView1" Name="empEmployeeNo" PropertyName="SelectedValue" Type="String" />
        </SelectParameters>     
    </asp:AccessDataSource>

    <!--// ***************************   FormView *********************************** //-->
      
    <asp:FormView ID="FormView1" runat="server" DataSourceID="AccessDataSource2" DataKeyNames = "CustomerNo"
        OnItemInserting="FormViewInserting"
        OnItemUpdating="FormViewUpdating"
       
        BorderColor="#333300" CellPadding="4" HeaderStyle-BackColor="#cccc99"
        RowStyle-BackColor="#ffffff" AlternatingRowStyle-BackColor="#cccccc"
        Font-Size="8pt"
           
        style="z-index: 106; left: 138px; top: 371px; position: absolute; height: 263px; width: 840px"
        BorderStyle="Solid" BorderWidth="1pt">
       
                 
        <%-- EditItem Template --%>
        <RowStyle BackColor="#006666" ForeColor="#CCCCCC" />
        <EditItemTemplate>
             
         <asp:Label ID="lblCompanyName" runat="server" font-size="11pt" Text="Company name : " style="z-index: 1; left: 280px; top: 10px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxCompanyName" runat="server" font-size="9pt" Text='<%# Eval("CompanyName") %>' style="z-index: 1; left: 395px; top: 10px; position: absolute"></asp:TextBox>
        
         <asp:Label ID="lblContactName" runat="server" font-size="11pt" Text="Contact name : " style="z-index: 1; left: 6px; top: 38px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxContactName" runat="server" font-size="9pt" Text='<%# Eval("ContactName") %>' style="z-index: 1; left: 108px; top: 43px; position: absolute"></asp:TextBox>
        
         <asp:Label ID="lblTitle" runat="server" font-size="11pt" Text="Title : " style="z-index: 1; left: 280px; top: 38px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxTitle" runat="server" font-size="9pt" Text='<%# Eval("Title") %>' style="z-index: 1; left: 395px; top: 38px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblAddress" runat="server" font-size="11pt" Text="Address : " style="z-index: 1; left: 6px; top: 68px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxAddress" runat="server" font-size="9pt" Text='<%# Eval("Address") %>' style="z-index: 1; left: 110px; top: 72px; width:300px; position: absolute"></asp:TextBox>
        
         <asp:Label ID="lblTelNo1" runat="server" font-size="11pt" Text="Tel. 1: " style="z-index: 1; left: 6px; top: 98px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxTelNo1" runat="server" font-size="9pt" Text='<%# Eval("TelNo1") %>' style="z-index: 1; left: 110px; top: 100px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblTelNo2" runat="server" font-size="11pt" Text="Tel. 2: " style="z-index: 1; left: 280px; top: 98px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxTelNo2" runat="server" font-size="9pt" Text='<%# Eval("TelNo2") %>' style="z-index: 1; left: 395px; top: 98px; position: absolute"></asp:TextBox>
           
         <asp:Label ID="lblFaxNo" runat="server" font-size="11pt" Text="Fax no. : " style="z-index: 1; left: 6px; top: 125px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxFaxNo" runat="server" font-size="9pt" Text='<%# Eval("FaxNo") %>' style="z-index: 1; left: 110px; top: 125px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblMobile" runat="server" font-size="11pt" Text="Mobile : " style="z-index: 1; left: 280px; top: 125px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxMobile" runat="server" font-size="9pt" Text='<%# Eval("Mobile") %>' style="z-index: 1; left: 395px; top: 125px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblEmail" runat="server" font-size="11pt" Text="Email : " style="z-index: 1; left: 6px; top: 160px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxEmail" runat="server" font-size="9pt" Text='<%# Eval("Email") %>' style="z-index: 1; left: 110px; top: 160px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblWebSite" runat="server" font-size="11pt" Text="Web site : " style="z-index: 1; left: 5px; top: 195px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxWebSite" runat="server" font-size="9pt" Text='<%# Eval("Website") %>' style="z-index: 1; left: 110px; top: 195px; position: absolute"></asp:TextBox>
        
         <asp:Label ID="lblPrint" runat="server" font-size="10pt" Text="列印 : " style="z-index: 1; left: 280px; top: 155px; position: absolute"></asp:Label>
         <asp:checkBox ID="ckbPrint" runat="server" font-size="10pt" Checked='<%# Eval("Print") %>' style="z-index: 1; left: 330px; top: 155px; position: absolute"/>
             
         <asp:Label ID="lblChineseName" runat="server" font-size="10pt" Text="營業代表 : " style="z-index: 1; left: 580px; top: 10px; position: absolute"></asp:Label>
         <%-- <asp:TextBox ID="tbxEmployeeNo" runat="server" font-size="10pt" Text='<%# Eval("EmployeeNo") %>' style="z-index: 1; left: 650px; top:11px; position: absolute"></asp:TextBox> --%>
         
         <asp:DropDownList ID="ddlEmployeeNo"  DataSourceId="AccessDataSource3" DataTextField="ChineseName" DataValueField="emp"  runat="server"
                 SelectedValue='<%# Eval("EmployeeNo") %>' style="z-index: 1; left: 750px; top: 11px; position: absolute" >

          
         </asp:DropDownList>
        
        
         <td colspan="3"style="border-bottom-width: medium; border-bottom-style: ridge; ">
         <asp:Button ID="UpdateButton" Text="Update" CommandName="Update" runat="server" CausesValidation="True" font-size="8pt" style="z-index: 1; left: 6px; top: 230px; position: absolute; height: 25px; width: 55px"/>
          &nbsp;
         <asp:Button ID="UpdateCancelButton" Text="Cancel" CommandName="Cancel" runat="server" CausesValidation="False" font-size="8pt" style="z-index: 1; left: 80px; top: 230px; position: absolute; height: 25px; width: 55px"/>
         </EditItemTemplate>
       
        
       
        <%-- InsertItem Template --%>
        <InsertItemTemplate>
         <asp:Label ID="lblCompanyName" runat="server" font-size="11pt" Text="Company name : " style="z-index: 1; left: 280px; top: 10px; position: absolute"></asp:Label>
        <asp:TextBox ID="tbxCompanyName" runat="server" font-size="10pt" Text='<%# Bind("CompanyName") %>' style="z-index: 1; left: 390px; top: 10px; position: absolute"></asp:TextBox>
        
        <asp:Label ID="lblContactName" runat="server" font-size="11pt" Text="Contact name : " style="z-index: 1; left: 6px; top: 38px; position: absolute"></asp:Label>
        <asp:TextBox ID="tbxContactName" runat="server" font-size="10pt" Text='<%# Bind("ContactName") %>' style="z-index: 1; left: 108px; top: 43px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblTitle" runat="server" font-size="11pt" Text="Title : " style="z-index: 1; left: 280px; top: 38px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxTitle" runat="server" font-size="10pt" Text='<%# Bind("Title") %>' style="z-index: 1; left: 390px; top: 38px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblAddress" runat="server" font-size="11pt" Text="Address : " style="z-index: 1; left: 6px; top: 68px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxAddress" runat="server" font-size="10pt" Text='<%# Bind("Address") %>' style="z-index: 1; left: 110px; top: 72px; position: absolute"></asp:TextBox>
        
         <asp:Label ID="lblTelNo1" runat="server" font-size="11pt" Text="Tel. 1: " style="z-index: 1; left: 6px; top: 98px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxTelNo1" runat="server" font-size="10pt" Text='<%# Bind("TelNo1") %>' style="z-index: 1; left: 110px; top: 100px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblTelNo2" runat="server" font-size="11pt" Text="Tel. 2: " style="z-index: 1; left: 280px; top: 98px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxTelNo2" runat="server" font-size="10pt" Text='<%# Bind("TelNo2") %>' style="z-index: 1; left: 390px; top: 98px; position: absolute"></asp:TextBox>
           
         <asp:Label ID="lblFaxNo" runat="server" font-size="11pt" Text="Fax no. : " style="z-index: 1; left: 6px; top: 125px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxFaxNo" runat="server" font-size="10pt" Text='<%# Bind("FaxNo") %>' style="z-index: 1; left: 110px; top: 125px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblMobile" runat="server" font-size="11pt" Text="Mobile : " style="z-index: 1; left: 280px; top: 125px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxMobile" runat="server" font-size="10pt" Text='<%# Bind("Mobile") %>' style="z-index: 1; left: 390px; top: 125px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblEmail1" runat="server" font-size="11pt" Text="Email : " style="z-index: 1; left: 6px; top: 160px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxEmail2" runat="server" font-size="10pt" Text='<%# Bind("Email") %>' style="z-index: 1; left: 110px; top: 160px; position: absolute"></asp:TextBox>
       
         <asp:Label ID="lblWebSite" runat="server" font-size="11pt" Text="Web site : " style="z-index: 1; left: 5px; top: 195px; position: absolute"></asp:Label>
         <asp:TextBox ID="tbxWebSite" runat="server" font-size="10pt" Text='<%# Bind("Website") %>' style="z-index: 1; left: 110px; top: 195px; position: absolute"></asp:TextBox>
        
         <td colspan="3"style="border-bottom-width: medium; border-bottom-style: ridge; ">
         <asp:Button ID="InsertButton" Text="Insert" CommandName="Insert" runat="server" CausesValidation="True" font-size="8pt" style="z-index: 1; left: 6px; top: 230px; position: absolute; height: 25px; width: 55px"/>
           &nbsp;
         <asp:Button ID="InsertCancelButton" Text="Cancel" CommandName="Cancel" runat="server" CausesValidation="False" font-size="8pt" style="z-index: 1; left: 80px; top: 230px; position: absolute; height: 25px; width: 55px"/>
         </InsertItemTemplate>
       
        <%-- Item Template --%>
        <ItemTemplate>
         <asp:Label ID="lblCustomerNo" runat="server" font-size="11pt" Text="Customer no. : " style="z-index: 1; left: 6px; top: 10px; position: absolute"></asp:Label>
         <asp:Label ID="tbxCustomerNo" runat="server" font-size="10pt" Text='<%# Eval("CustomerNo") %>' style="z-index: 1; left: 108px; top: 10px; position: absolute"></asp:Label>
        
         <asp:Label ID="lblCompanyName" runat="server" font-size="11pt" Text="Company name : " style="z-index: 1; left: 280px; top: 10px; position: absolute"></asp:Label>
         <asp:Label ID="tbxCompanyName" runat="server" font-size="10pt" Text='<%# Bind("CompanyName") %>' style="z-index: 1; left: 390px; top: 12px; position: absolute"></asp:Label>
        
         <asp:Label ID="lblContactName" runat="server" font-size="11pt" Text="Contact name : " style="z-index: 1; left: 6px; top: 38px; position: absolute"></asp:Label>
         <asp:Label ID="tbxContactName" runat="server" font-size="10pt" Text='<%# Bind("ContactName") %>' style="z-index: 1; left: 108px; top: 43px; position: absolute"></asp:Label>
       
         <asp:Label ID="lblTitle" runat="server" font-size="11pt" Text="Title : " style="z-index: 1; left: 280px; top: 38px; position: absolute"></asp:Label>
         <asp:Label ID="tbxTitle" runat="server" font-size="10pt" Text='<%# Bind("Title") %>' style="z-index: 1; left: 390px; top: 38px; position: absolute"></asp:Label>
       
         <asp:Label ID="lblAddress" runat="server" font-size="11pt" Text="Address : " style="z-index: 1; left: 6px; top: 68px; position: absolute"></asp:Label>
         <asp:Label ID="tbxAddress" runat="server" font-size="10pt" Text='<%# Bind("Address") %>' style="z-index: 1; left: 110px; top: 72px; position: absolute"></asp:Label>
        
         <asp:Label ID="lblTelNo1" runat="server" font-size="11pt" Text="Tel. 1 : " style="z-index: 1; left: 6px; top: 98px; position: absolute"></asp:Label>
         <asp:Label ID="tbxTelNo1" runat="server" font-size="10pt" Text='<%# Bind("TelNo1") %>' style="z-index: 1; left: 110px; top: 100px; position: absolute"></asp:Label>
       
         <asp:Label ID="lblTelNo2" runat="server" font-size="11pt" Text="Tel. 2 : " style="z-index: 1; left: 280px; top: 98px; position: absolute"></asp:Label>
         <asp:Label ID="tbxTelNo2" runat="server" font-size="10pt" Text='<%# Bind("TelNo2") %>' style="z-index: 1; left: 380px; top: 98px; position: absolute"></asp:Label>
           
         <asp:Label ID="lblFaxNo1" runat="server" font-size="11pt" Text="Fax no. : " style="z-index: 1; left: 6px; top: 125px; position: absolute"></asp:Label>
         <asp:Label ID="tbxFaxNo2" runat="server" font-size="10pt" Text='<%# Bind("FaxNo") %>' style="z-index: 1; left: 110px; top: 125px; position: absolute"></asp:Label>
       
         <asp:Label ID="lblMobile" runat="server" font-size="11pt" Text="Mobile : " style="z-index: 1; left: 280px; top: 125px; position: absolute"></asp:Label>
         <asp:Label ID="tbxMobile" runat="server" font-size="10pt" Text='<%# Bind("Mobile") %>' style="z-index: 1; left: 380px; top: 125px; position: absolute"></asp:Label>
       
         <asp:Label ID="lblEmail" runat="server" font-size="11pt" Text="Email : " style="z-index: 1; left: 6px; top: 160px; position: absolute"></asp:Label>
         <asp:Label ID="tbxEmail" runat="server" font-size="10pt" Text='<%# Bind("Email") %>' style="z-index: 1; left: 110px; top: 160px; position: absolute"></asp:Label>
       
         <asp:Label ID="lblWebSite1" runat="server" font-size="11pt" Text="Web site : " style="z-index: 1; left: 5px; top: 195px; position: absolute"></asp:Label>
         <asp:Label ID="tbxWebSite2" runat="server" font-size="10pt" Text='<%# Bind("Website") %>' style="z-index: 1; left: 110px; top: 195px; position: absolute"></asp:Label>
        
         <asp:Label ID="lblPrint" runat="server" font-size="10pt" Text="列印 : " style="z-index: 1; left: 280px; top: 155px; position: absolute"></asp:Label>
         <asp:Label ID="tbxPrint" runat="server" font-size="10pt" Text='<%# Bind("Print") %>' style="z-index: 1; left: 330px; top: 155px; position: absolute"></asp:Label>
            
         <asp:Label ID="lblAttn" runat="server" font-size="10pt" Text="是否列印收件人 :  " style="z-index: 1; left: 280px; top: 185px; position: absolute"></asp:Label>
         <asp:Label ID="tbxAttn" runat="server" font-size="10pt" Text='<%# Bind("Attn") %>' style="z-index: 1; left: 385px; top: 185px; position: absolute"></asp:Label>
        
         <asp:Label ID="lblXmaxCard" runat="server" font-size="10pt" Text="是否要郵寄聖誕咭 :  " style="z-index: 1; left: 280px; top: 215px; position: absolute"></asp:Label>
         <asp:Label ID="tbxXmasCard" runat="server" font-size="10pt" Text='<%# Bind("XmasCard") %>' style="z-index: 1; left: 395px; top: 215px; position: absolute"></asp:Label>
        
         <asp:Label ID="lblChineseName1" runat="server" font-size="10pt" Text="營業代表 : " style="z-index: 1; left: 580px; top: 10px; position: absolute"></asp:Label>
         <asp:Label ID="tbxChineseName2" runat="server" font-size="10pt" Text='<%# Bind("ChineseName") %>' style="z-index: 1; left: 650px; top:11px; position: absolute"></asp:Label>
        
         <asp:Label ID="lblLocationName" runat="server" font-size="10pt" Text="地區 : " style="z-index: 1; left: 580px; top: 40px; position: absolute"></asp:Label>
         <asp:Label ID="tbxLocationName" runat="server" font-size="10pt" Text='<%# Bind("LocationName") %>' style="z-index: 1; left: 650px; top:40px; position: absolute"></asp:Label>
        
         <asp:Label ID="lblAreaName" runat="server" font-size="10pt" Text="位置 : " style="z-index: 1; left: 580px; top: 70px; position: absolute"></asp:Label>
         <asp:Label ID="tbxAreaName" runat="server" font-size="10pt" Text='<%# Bind("AreaName") %>' style="z-index: 1; left: 650px; top:70px; position: absolute"></asp:Label>
        
             
          <td colspan="3"style="border-bottom-width: medium; border-bottom-style: ridge; ">
          <asp:Button ID="btnEdit" Text="Edit" CommandName="Edit" runat="server" font-size="8pt" style="z-index: 1; left: 6px; top: 230px; position: absolute; height: 25px; width: 50px"/>
          <asp:Button ID="btnDelete" runat="server" CommandName="Delete" OnClientClick="return confirm('Are you sure ?')" Text="Delete" font-size="8pt" style="z-index: 1; left: 80px; top: 230px; position: absolute; height: 25px; width: 50px"/>
          <asp:Button ID="btnInsert" Text="Insert" CommandName="New" runat="server" font-size="8pt" style="z-index: 1; left: 150px; top: 230px; position: absolute; height: 25px; width: 50px"/>
        </ItemTemplate>
        <HeaderStyle BackColor="#CCCC99" />
        <EditRowStyle ForeColor="#CCCCCC" BackColor="#006666" />
    </asp:FormView>

    <!--// ***************************   GridView *********************************** //-->
         
    <asp:GridView ID="myGridView" Runat="server" DataSourceID="AccessDataSource1"
        SelectedIndex="0" AutoGenerateSelectButton="True" DataKeyNames="CustomerNo"
        BorderColor="Black" CellPadding="4" HeaderStyle-BackColor="#cccc99"
        RowStyle-BackColor="#ffffff" AlternatingRowStyle-BackColor="#cccccc"
        Font-Size="8pt" AllowPaging="True" AutoGenerateColumns="False"
        style="z-index: 106; left: 136px; position: absolute; top: 78px; width: 841px;"
        Height="194px" AllowSorting="True">
        <Columns>
            <asp:BoundField HeaderText="Company Name" DataField="CompanyName" SortExpression="CompanyName" />
            <asp:BoundField HeaderText="Contact Person" DataField="ContactName" SortExpression="ContactName" />
            <asp:BoundField HeaderText="Title" DataField="Title" SortExpression="Title" />
            <asp:BoundField HeaderText="Address" DataField="Address" SortExpression="Address" />
            <asp:BoundField HeaderText="Tel No. 1" DataField="TelNo1" SortExpression="TelNo1" />
            <asp:BoundField HeaderText="Tel No. 2" DataField="TelNo2" SortExpression="TelNo2" />
        </Columns>
          <RowStyle BackColor="White" /><HeaderStyle BackColor="#CCCC99" /><AlternatingRowStyle BackColor="#CCCCCC" />
    </asp:GridView>

    </asp:Content>

     

    Filed under:
  • Re: Drop down list problem

    08-01-2009, 9:53 AM
    • All-Star
      89,616 point All-Star
    • SGWellens
    • Member since 01-02-2007, 9:27 PM
    • Twin Cities, MN
    • Posts 7,322
    • Moderator
      TrustedFriends-MVPs

    What is the error?

    Where does it occur?

    Steve Wellens

    My blog
  • Re: Drop down list problem

    08-01-2009, 10:36 AM
    Try, EmployeeNo.SelectedItem.Text


    Mark as Answer
    on the posts replys that helped you.
    My Blog -: MSChart

  • Re: Drop down list problem

    08-01-2009, 5:18 PM
    Answer
    • Star
      8,702 point Star
    • hans_v
    • Member since 01-29-2007, 9:03 PM
    • Posts 1,499

    My goodness..... I really don't know where to start?

    When you want to display the fields in some sort of table, use the detailsview instead of a formview, it will save you a lot of time! If you want to have some more control about the look and feel of you textboxes, use a templatefield. And it is a good idea to use some Css and/or skins, if you want all textboxes and other controls to have the same look and feel, instead of repeating the same code over and over again!

    In the ItemTemplate and InsertTemplate you bind the labels and textboxes using 2 way binding, however, in the edittemplate you're using one way binding (Eval instead of Bind), resulting in the code in ViewUpdating event. When you're using two way binding, you can skip this code. Since you use two way binding in the InsertTemplate, the code in the ViewInserting Event isn't requered also!

    The problem is that you didn't declase any Update (Insert And Delete) Parameters in AccessDataSource control:

    <asp:AccessDataSource ID="AccessDataSource2" runat="server" 
        DataFile="~/App_Data/FATTAT.db1.mdb" 
        SelectCommand="..." 
        UpdateCommand="UPDATE tblCustomer SET CompanyName=@CompanyName, ContactName=@ContactName, Title=@Title,
                                        Address=@Address, TelNo1=@TelNo1, TelNo2=@TelNo2, FaxNo=@FaxNo, Mobile=@Mobile,
                                        Email=@Email, WebSite=@WebSite, Print=@Print,
                                        EmployeeNo=emp
                                        WHERE CustomerNo=@CustomerNo"
        DeleteCommand="...."
        InsertCommand="....">
        <SelectParameters>
          <asp:ControlParameter ControlID="myGridView" Name="CustomerNo" PropertyName="SelectedValue" Type="String" />
        </SelectParameters>
        <UpdateParameters>
          <asp:Parameter Name="companyName" Type="String" />
          <asp:Parameter Name="ContactName" Type="String" />
          <asp:Parameter Name="Title" Type="String" />
          <asp:Parameter Name="Address" Type="String" />
          <asp:Parameter Name="TelNo1" Type="String" />
          <asp:Parameter Name="TelNo2" Type="String" />
          <asp:Parameter Name="FaxNo" Type="String" />
          <asp:Parameter Name="Email" Type="String" />
          <asp:Parameter Name="WebSite" Type="String" />
          <asp:Parameter Name="Print" Type="String" />
          <asp:Parameter Name="EmployeeNo" Type="Int16" />
          <asp:Parameter Name="CustomerNo" Type="Int16" />
        </UpdateParameters>
        <InsertParameters>
    	.....
        </InsertParameters>
        <DeleteParameters>
    	.....
        </DeleteParameters>
    </asp:AccessDataSource>

    I only specified the UpdateCommand and Parameters, Note that the parameters must be added in the same order as they appear in the SQL Command.


     

  • Re: Drop down list problem

    09-14-2009, 9:53 AM
    • Member
      18 point Member
    • vishal bhatt
    • Member since 09-11-2009, 11:08 AM
    • Pune, India
    • Posts 6

    Now that's a long long code.......but what is the error? Where does it occur
    You can try with something like EmployeeNo.SelectedItem.Text

    Now that's a very long code.......but what is the error? Where does it occur


    You can try with something like EmployeeNo.SelectedItem.Text

    Thanks,

    Vishal Bhatt
    My Linkedin

    "Believe you can change the world."

Page 1 of 1 (5 items)