当下拉值更改时,尝试更改我的网页上的标签

时间:2015-10-09 12:32:24

标签: c# jquery asp.net

在下拉列表中选择了不同的下拉列值时,无法尝试更改标签。任何帮助将不胜感激,这是页面的代码

.aspx文件

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Incidents Report</title>
</head>
<body>
  <form id="form1" runat="server">
  <div>

    <asp:DropDownList ID="ddlIncidents" 
    runat="server"DataSourceID="TechSupportDataSource" 
    DataTextField="Tickets" DataValueField="IncidentID" AutoPostBack="True" 
    OnSelectedIndexChanged="ddlIncidents_SelecetedIndexChanged">
    </asp:DropDownList>

  </div>
    <asp:SqlDataSource ID="TechSupportDataSource" runat="server" 
    ConnectionString="<%$ ConnectionStrings:AccessString %>" ProviderName="
    <%$ ConnectionStrings:AccessString.ProviderName %>" 
    SelectCommand="SELECT CSTR(IncidentID) + ' | ' +  ProductCode + ' | ' + 
    Title  AS Tickets, * FROM [Incidents] WHERE ([CustomerID] = ?)">
        <SelectParameters>
            <asp:SessionParameter DefaultValue="1116" Name="CustomerID" 
             SessionField="CustID" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:Label ID="Label4" runat="server" Font-Overline="False" Font-
      Size="X-Large" Font-Underline="True" Text="Customer Info"></asp:Label>
    <br />
     &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label1" runat="server" Font-Bold="True" Text="Name: "> 
    </asp:Label>
    <asp:Label ID="lblName" runat="server" Text="Label"></asp:Label>
    <br />
    &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label2" runat="server" Font-Bold="True" Text="Contact: ">
    </asp:Label>
    <asp:Label ID="lblContact" runat="server" Text="Label"></asp:Label>
    <br />
    &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Address: ">
    </asp:Label>
    <asp:Label ID="lblAddress" runat="server" Text="Label"></asp:Label>
    <br />
    <asp:Label ID="Label5" runat="server" Font-Size="X-Large" Font-
    Underline="True" Text="Ticket Info"></asp:Label>
    <br />
    &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label6" runat="server" Font-Bold="True" Text="Incident 
    ID: "></asp:Label>
    <asp:Label ID="lblIncidentID" runat="server" Text="Label"></asp:Label>
    <br />
    &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label7" runat="server" Font-Bold="True" Text="Title: ">
    </asp:Label>
    <asp:Label ID="lblTitle" runat="server" Text="Label"></asp:Label>
    <br />
    &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label8" runat="server" Font-Bold="True" 
     Text="Description: "></asp:Label>
    <asp:Label ID="lblDescription" runat="server" Text="Label"></asp:Label>
    <br />
    &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label10" runat="server" Font-Bold="True" Text="Date 
     Opened: "></asp:Label>
    <asp:Label ID="lblOpened" runat="server" Text="Label"></asp:Label>
    <br />
    &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label11" runat="server" Font-Bold="True" Text="Date 
     Closed: "></asp:Label>
    <asp:Label ID="lblClosed" runat="server" Text="Label"></asp:Label>
    <br />
    &nbsp;&nbsp;&nbsp;
    <asp:Label ID="Label9" runat="server" Font-Bold="True" Text="Technician 
     Name: "></asp:Label>
    <asp:Label ID="lblTechnician" runat="server" Text="Label"></asp:Label>
   </form>
   </body>
   </html>

和.CS文件

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Default2 : System.Web.UI.Page
{
private Incident incident;
protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
    {
        ddlIncidents.DataBind();
    }
    incident = this.GetIncident();
    lblName.Text = Session["CustomerName"].ToString();
    lblContact.Text = Session["CustomerContact"].ToString();
    lblAddress.Text = Session["CustomerAddress"].ToString();
    lblIncidentID.Text = incident.incidentNum;
    lblTitle.Text = incident.title;
    lblDescription.Text = incident.description;
    lblOpened.Text = incident.dateOpen;
    lblClosed.Text = incident.dateClosed;
    lblTechnician.Text = incident.techName;
}

private Incident GetIncident()
{
    DataView incidentTable = (DataView)
       TechSupportDataSource.Select(DataSourceSelectArguments.Empty);

    DataRowView row = incidentTable[0];

    Incident i = new Incident();
    i.incidentNum = row["IncidentID"].ToString();
    i.productName = row["ProductCode"].ToString();
    i.title = row["Title"].ToString();
    i.techName = row["TechID"].ToString();
    i.dateOpen = row["DateOpened"].ToString();
    i.dateClosed = row["DateClosed"].ToString();
    i.description = row["Description"].ToString();

    return i;
}
}

0 个答案:

没有答案