datalist中droplist联动的处理

<%@ Page language="c#" Codebehind="Operation_Add.aspx.cs" AutoEventWireup="false" Inherits="WHMIS.MyJob.MyInterview.Operation_Add" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
  <title>业务信息补充</title>
<meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
<meta content=C# name=CODE_LANGUAGE>
<meta content=JavaScript name=vs_defaultClientScript>
<meta content=http://schemas.microsoft.com/intellisense/ie5 name=vs_targetSchema><LINK href="../../CSS/main.css" type=text/css rel=stylesheet >
  </HEAD>
<body leftMargin=0 topMargin=0 MS_POSITIONING="GridLayout">
<div align=left>
<form id=Form1 method=post runat="server">
<TABLE id=Table3 style="WIDTH: 488px; HEIGHT: 61px" cellSpacing=1 cellPadding=1
width=488 border=0>
  <TR>
    <TD style="HEIGHT: 20px" align=right colSpan=3><FONT
      face=宋体><asp:button id=addBut runat="server" CssClass="button" Text="新增业务信息"></asp:button>&nbsp;

      <HR width="100%" color=#330033 SIZE=1>
      </FONT>
      <TABLE id=Table2 style="WIDTH: 488px; HEIGHT: 94px" cellSpacing=1
      borderColorDark=#ffffcc cellPadding=1 width=488 border=1
       runat="server">
        <TR>
          <TD><FONT face=宋体
            >客户名称</FONT></TD>
          <TD><FONT face=宋体><asp:textbox id=addCust_name runat="server" CssClass="text" ReadOnly="True"></asp:textbox></FONT></TD>
          <TD>服务提供商</TD>
          <TD><asp:dropdownlist id=addServerBus_name runat="server" AutoPostBack="True"></asp:dropdownlist></TD></TR>
        <TR>
          <TD style="HEIGHT: 18px"><FONT face=宋体
            >业务名称</FONT></TD>
          <TD style="HEIGHT: 18px"><asp:dropdownlist id=addServer_name runat="server"></asp:dropdownlist></TD>
          <TD style="HEIGHT: 18px"><FONT face=宋体
            >电话号码</FONT></TD>
          <TD style="HEIGHT: 18px"><asp:textbox id=addPhone_Num runat="server" CssClass="text" ReadOnly="True"></asp:textbox></TD></TR>
        <TR>
          <TD><FONT face=宋体
            >业务说明</FONT></TD>
          <TD colSpan=3><FONT face=宋体
            ><asp:textbox id=addServer_View runat="server" CssClass="text" TextMode="MultiLine" Width="372px"></asp:textbox></FONT></TD></TR>
        <TR>
          <TD align=center colSpan=4><FONT face=宋体
            ><asp:button id=saveBut runat="server" CssClass="Button" Text="保  存" Width="55px"></asp:button><asp:label id=resultLab runat="server" Width="75px" ForeColor="Red"></asp:label><asp:button id=closeBut runat="server" CssClass="Button" Text="关  闭" Width="56px"></asp:button></FONT></TD></TR></TABLE></TD></TR></TABLE>
<TABLE id=Table1 style="WIDTH: 496px" cellSpacing=1 cellPadding=1 width=496
border=0>
  <TBODY>
  <TR>
    <TD colSpan=3><FONT face=宋体><asp:datalist id=dlgOperation runat="server" Width="100%" ForeColor="Black" BorderColor="#999999" BorderStyle="Solid" BackColor="White" CellPadding="3" GridLines="Vertical" BorderWidth="1px">
<SelectedItemStyle Font-Bold="True" ForeColor="White" BackColor="#000099">
</SelectedItemStyle>

<HeaderTemplate>
           <FONT face="宋体">业务信息列表</FONT>
          
</HeaderTemplate>

<SelectedItemTemplate>
<FONT face=宋体></FONT>
</SelectedItemTemplate>

<AlternatingItemStyle BackColor="#CCCCCC">
</AlternatingItemStyle>

<ItemTemplate>
<TABLE id=Table5 cellSpacing=1 cellPadding=1 width="100%" border=0>
<TR>
<TD>客户名称:</TD>
<TD>
<asp:Label id=lbCust_Name runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Customer_Name") %>' Width="100px" ToolTip='<%# DataBinder.Eval(Container, "DataItem.Operation_id") %>'>
              </asp:Label></TD>
<TD>服务商:</TD>
<TD colSpan=2>
<asp:Label id=lblServSuper runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Serv_Supper_Name") %>' ToolTip='<%# DataBinder.Eval(Container, "DataItem.Serv_Supper_ID") %>'>
              </asp:Label></TD></TR>
<TR>
<TD>业务名称:</TD>
<TD>
<asp:Label id=lblServer runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Serv_Name") %>' ToolTip='<%# DataBinder.Eval(Container, "DataItem.Serv_ID") %>'>
              </asp:Label></TD>
<TD>电话号码:</TD>
<TD>
<asp:Label id=lbTel_Num runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Tel_Num") %>' Width="66px">
              </asp:Label></TD></TR>
<TR>
<TD>业务说明:</TD>
<TD colSpan=2><FONT face=宋体>
<asp:Label id=lbServ_View runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.Serv_View") %>' Width="251px">
               </asp:Label></FONT></TD>
<TD align=right>
<asp:Button id=btnedit runat="server" CssClass="Button" Text="编 辑" Width="44px" CommandName="edit"></asp:Button>
<asp:Button id=delBut runat="server" CssClass="Button" Text="删 除" Width="44px" CommandName="delete"></asp:Button></TD></TR></TABLE>
</ItemTemplate>

<FooterStyle BackColor="#CCCCCC">
</FooterStyle>

<HeaderStyle Font-Bold="True" ForeColor="White" BackColor="Black">
</HeaderStyle>

<EditItemTemplate>
<FONT face=宋体><FONT face=宋体>
<TABLE id=Table4 cellSpacing=1 cellPadding=1 width="100%" border=0>
<TR>
<TD>客户名称:</TD>
<TD><FONT face=宋体>
<asp:TextBox id=txCust_Name runat="server" CssClass="text" Text='<%# DataBinder.Eval(Container, "DataItem.Customer_Name") %>' ReadOnly="True" Width="112px">
                 </asp:TextBox></FONT></TD>
<TD>服务商:</TD>
<TD colSpan=2>
<asp:DropDownList id=drServ_Sup runat="server" AutoPostBack="True" OnSelectedIndexChanged="ChangeDropList"></asp:DropDownList></TD></TR>
<TR>
<TD>业务名称:</TD>
<TD>
<asp:DropDownList id=drServ_Name runat="server"></asp:DropDownList></TD>
<TD>电话号码:</TD>
<TD>
<asp:TextBox id=txTel_Num runat="server" CssClass="text" Text='<%# DataBinder.Eval(Container, "DataItem.Tel_Num") %>' ReadOnly="True" Width="114px">
                </asp:TextBox></TD></TR>
<TR>
<TD>业务说明:</TD>
<TD colSpan=2><FONT face=宋体>
<asp:TextBox id=txServ_View runat="server" CssClass="text" Text='<%# DataBinder.Eval(Container, "DataItem.Serv_View") %>' TextMode="MultiLine" Width="205px">
                 </asp:TextBox></FONT></TD>
<TD align=right>
<asp:Button id=chSaveBut runat="server" CssClass="Button" Text="保 存" CommandName="update"></asp:Button>
<asp:Button id=chCloseBut runat="server" CssClass="Button" Text="关 闭" CommandName="cancel"></asp:Button></TD></TR></TABLE></FONT></FONT>
</EditItemTemplate>
</asp:datalist></FONT></TD></TR>
  <TR>
    <TD></TD>
    <TD></TD>
    <TD><FONT face=宋体
  ></FONT></TD></TR></TBODY></TABLE>&nbsp;
</FORM></DIV></TR></TBODY></TABLE></FORM>
<DIV></DIV>
 </body>
</HTML>


cs程序

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Mindsware.Core.Misc;
using WHMIS.Misc;
using WHMIS.DataObjects;
using System.Data.SqlClient;
using System.Data.Odbc;

namespace WHMIS.MyJob.MyInterview
{
 /// <summary>
 /// Operation_Add 的摘要说明。
 /// </summary>
 public class Operation_Add : System.Web.UI.Page
 {
  protected System.Web.UI.WebControls.Button addBut;
  protected System.Web.UI.HtmlControls.HtmlTable Table2;
  protected System.Web.UI.WebControls.Button saveBut;
  protected System.Web.UI.WebControls.Button closeBut;
  protected System.Web.UI.WebControls.Label resultLab;
  protected System.Web.UI.WebControls.TextBox addCust_name;
  protected System.Web.UI.WebControls.TextBox addPhone_Num;
  protected System.Web.UI.WebControls.TextBox addServer_View;
  protected System.Web.UI.WebControls.DropDownList addServerBus_name;
  protected System.Web.UI.WebControls.DropDownList addServer_name;
  protected System.Web.UI.HtmlControls.HtmlForm Form1;
  protected System.Web.UI.WebControls.Label LabCUST_NAME;
  protected System.Web.UI.WebControls.Label lblServBus;
  protected System.Web.UI.WebControls.Label lblServerName;
  protected System.Web.UI.WebControls.Label lblPhoneNum;
  protected System.Web.UI.WebControls.Label LABSERVERVIEW;
  protected System.Web.UI.WebControls.Button btnUpdate;
  protected System.Web.UI.WebControls.Button btnDelete;
  protected System.Web.UI.WebControls.DropDownList DropserverBus;
  protected System.Web.UI.WebControls.Label CUST_NAME;
  protected System.Web.UI.WebControls.DropDownList DropserverName;
  protected System.Web.UI.WebControls.Label PhoneNum;
  protected System.Web.UI.WebControls.TextBox serverView;
  protected System.Web.UI.WebControls.Button Button3;
  protected System.Web.UI.WebControls.DataList dlgOperation;
  protected string UserName;
  protected  string Serv_Supper_ID="";
  protected  string Serv_ID="";
  protected int dlitemindex=0;
  private string customer_id
  {
   get
   {
    return (ViewState["customer_id"]==null)?"":(string)(ViewState["customer_id"]);
   }
   set
   {
    ViewState["customer_id"] = value;
   }
  }
  private string list_Sql
  {
   get
   {
    return (ViewState["list_Sql"]==null)?"":(string)(ViewState["list_Sql"]);
   }
   set
   {
    ViewState["list_Sql"] = value;
   }
  }
  private string Operation_id
  {
   get
   {
    return (ViewState["Operation_id"]==null)?"":(string)(ViewState["Operation_id"]);
   }
   set
   {
    ViewState["Operation_id"] = value;
   }
  }
  private void Page_Load(object sender, System.EventArgs e)
  {
   // 在此处放置用户代码以初始化页面
   if(!Page.IsPostBack)
   {
       this.Table2.Style["display"]="none";//隐藏添加内容
                //默认数据绑定
    InitDataBind();
    list_Sql="select a.Customer_Name as Customer_Name,b.Operation_id as Operation_id,b.Tel_Num as Tel_Num,b.Serv_Supper_Name as Serv_Supper_Name,b.Serv_Name as Serv_Name,b.Serv_View as Serv_View";
             list_Sql+=" ,b.Operation_id as Operation_id,b.Serv_Supper_Id as Serv_Supper_Id,b.Serv_ID as Serv_ID from JINGZHENG_CUSTBASE a RIGHT JOIN JINGZHENG_OPERATIONINFO b on a.Customer_Id=b.Customer_Id where b.Customer_Id="+int.Parse(customer_id)+"";
       dataListBind(list_Sql);
   }
   this.UserName= WHMIS.Misc.SysConfig.GetUserAccount(this.Page);
  }

  #region Web 窗体设计器生成的代码
  override protected void OnInit(EventArgs e)
  {
   //
   // CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
   //
   InitializeComponent();
   base.OnInit(e);
  }
  
  /// <summary>
  /// 设计器支持所需的方法 - 不要使用代码编辑器修改
  /// 此方法的内容。
  /// </summary>
  private void InitializeComponent()
  {   
   this.addBut.Click += new System.EventHandler(this.addBut_Click);
   this.addServerBus_name.SelectedIndexChanged += new System.EventHandler(this.addServerBus_name_SelectedIndexChanged);
   this.saveBut.Click += new System.EventHandler(this.saveBut_Click);
   this.closeBut.Click += new System.EventHandler(this.closeBut_Click);
   this.dlgOperation.CancelCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlgOperation_CancelCommand);
   this.dlgOperation.EditCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlgOperation_EditCommand);
   this.dlgOperation.UpdateCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlgOperation_UpdateCommand);
   this.dlgOperation.DeleteCommand += new System.Web.UI.WebControls.DataListCommandEventHandler(this.dlgOperation_DeleteCommand);
   this.dlgOperation.ItemDataBound += new System.Web.UI.WebControls.DataListItemEventHandler(this.dlgOperation_ItemDataBound);
   this.dlgOperation.SelectedIndexChanged += new System.EventHandler(this.dlgOperation_SelectedIndexChanged);
   this.Load += new System.EventHandler(this.Page_Load);

  }
  #endregion
  /// <summary>
  /// 初始化的数据邦定
  /// </summary>
  private void InitDataBind()
  {
      SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
   customer_id=this.Request["cust_id"].ToString().Trim();
   string sql="select * from JINGZHENG_CUSTBASE where Customer_Id="+int.Parse(customer_id)+"";
   System.Data.SqlClient.SqlDataAdapter mycomm=new SqlDataAdapter(sql,conn);
   DataSet myds=new DataSet();
   mycomm.Fill(myds,"JINGZHENG_CUSTBASE");

   this.addCust_name.Text=myds.Tables["JINGZHENG_CUSTBASE"].Rows[0]["Customer_Name"].ToString();//客户名称
   this.addPhone_Num.Text=myds.Tables["JINGZHENG_CUSTBASE"].Rows[0]["Customer_Tel"].ToString();  //客户电话

   //邦定服务商
   string sql1="select Serv_Supper_ID,Serv_Supper_Name from Comm_Serv_Supper group by Serv_Supper_ID,Serv_Supper_Name";
   System.Data.SqlClient.SqlDataAdapter mycomm1=new SqlDataAdapter(sql1,conn);
   DataSet myds1=new DataSet();
   mycomm1.Fill(myds1,"Comm_Serv_Supper");
   addServerBus_name.DataSource=myds1;
   addServerBus_name.DataValueField="Serv_Supper_ID";
   addServerBus_name.DataTextField="Serv_Supper_Name";
   addServerBus_name.DataBind();
   addServerBus_name.Items.Insert( 0,new ListItem("所有服务商","0") );

 

   //邦定达datalist
//   string list_Sql="select a.Customer_Name as Customer_Name,b.Tel_Num as Tel_Num,b.Serv_Supper_Name as Serv_Supper_Name,b.Serv_Name as Serv_Name,b.Serv_View as Serv_View";
//                   list_Sql+=" ,b.Operation_id as Operation_id,b.Serv_Supper_Id as Serv_Supper_Id,b.Serv_ID as Serv_ID from JINGZHENG_CUSTBASE a RIGHT JOIN JINGZHENG_OPERATIONINFO b on a.Customer_Id=b.Customer_Id where b.Customer_Id="+int.Parse(customer_id)+"";
//   System.Data.SqlClient.SqlCommand  listMycomm=new SqlCommand(list_Sql,conn);
//   conn.Close();
//   conn.Open();
//   System.Data.SqlClient.SqlDataReader myread=listMycomm.ExecuteReader ();
//   this.dlgOperation.DataSource=myread; 
//   this.dlgOperation.DataBind();
//   conn.Close();
  }
  private void dataListBind(string sql)
  {
   SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
   System.Data.SqlClient.SqlCommand  listMycomm=new SqlCommand(sql,conn);
   conn.Close();
   conn.Open();
   System.Data.SqlClient.SqlDataReader myread=listMycomm.ExecuteReader ();
   this.dlgOperation.DataSource=myread; 
   this.dlgOperation.DataBind();
   conn.Close();
  }
  private void addBut_Click(object sender, System.EventArgs e)
  {
   this.Table2.Style["display"]="block";
   this.saveBut.Enabled=true;
   this.dlgOperation.EditItemIndex=-1; 
  }

  private void closeBut_Click(object sender, System.EventArgs e)
  {
      this.Table2.Style["display"]="none";
  }
        /// <summary>
        /// 增加业务信息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
  private void saveBut_Click(object sender, System.EventArgs e)
  {
   if(this.addServerBus_name.SelectedIndex<=0)
   {
    Response.Write("<script language=javascript>");
    Response.Write("window.alert('请选择服务商');");
    Response.Write("</script>");
    return;
   }
   if(this.addServer_View.Text.ToString()=="")
   {
    Response.Write("<script language=javascript>");
    Response.Write("window.alert('业务说明不能为空');");
    Response.Write("</script>");
    return;
   }
   this.dlgOperation.EditItemIndex=-1;
   SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
   string insert_Sql="insert into JINGZHENG_OPERATIONINFO(Customer_Id,Tel_Num,Serv_Supper_Id,Serv_Supper_Name,Serv_ID,Serv_Name,Serv_View)";
                   insert_Sql+= " values("+int.Parse(customer_id.ToString())+",'"+this.addPhone_Num.Text.Trim()+"',"+int.Parse(this.addServerBus_name.SelectedValue.Trim())+",";
          insert_Sql+=" '"+addServerBus_name.SelectedItem.Text.Trim()+"',"+int.Parse(this.addServer_name.SelectedValue.Trim())+",'"+addServer_name.SelectedItem.Text.Trim()+"',";
          insert_Sql+=" '"+this.addServer_View.Text.Trim()+"')";
   System.Data.SqlClient.SqlCommand OPeration_InserMycomm=new SqlCommand(insert_Sql,conn);
   try
   {
    conn.Close();
    conn.Open();
    OPeration_InserMycomm.ExecuteNonQuery();
   }
   catch(Exception ex)
   {
    this.Response.Write(ex);
   }
   finally
   {
       this.resultLab.Visible=true;
    this.resultLab.Text="添加成功";
    this.saveBut.Enabled=false;
                dataListBind(list_Sql);
   }

  }

  private void addServerBus_name_SelectedIndexChanged(object sender, System.EventArgs e)
  {
   SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
   string sql="";
   if( addServerBus_name.SelectedValue != "0" )
     sql= "SELECT Serv_ID,Serv_Name FROM Comm_Serv WHERE Serv_Supper_ID = " + addServerBus_name.SelectedValue;
   else
    sql = "SELECT Serv_ID,Serv_Name FROM Comm_Serv";
   System.Data.SqlClient.SqlDataAdapter mycomm1=new SqlDataAdapter(sql,conn);
   DataSet myds1=new DataSet();
   mycomm1.Fill(myds1,"Comm_Serv");
   addServer_name.DataSource=myds1;
   addServer_name.DataValueField="Serv_ID";
   addServer_name.DataTextField="Serv_Name";
   addServer_name.DataBind();
   addServer_name.Items.Insert( 0,new ListItem("所有业务","0") );

  }

  protected void ChangeDropList(object sender, System.EventArgs e)
  {
   DropDownList dropdown = ( DropDownList)sender;
   dropdown=(DropDownList)this.dlgOperation.Items[this.dlitemindex].FindControl("drServ_Sup");
   SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
   string sql="";
   if( dropdown.SelectedValue != "0" )
    sql= "SELECT Serv_ID,Serv_Name FROM Comm_Serv WHERE Serv_Supper_ID = " + dropdown.SelectedValue;
   else
    sql = "SELECT Serv_ID,Serv_Name FROM Comm_Serv";
   System.Data.SqlClient.SqlDataAdapter mycomm1=new SqlDataAdapter(sql,conn);
   DataSet myds1=new DataSet();
   mycomm1.Fill(myds1,"Comm_Serv");
   DropDownList mydrop=new DropDownList();
   mydrop=(DropDownList)this.dlgOperation.Items[this.dlitemindex].FindControl("drServ_Name");
   mydrop.DataSource=myds1;
   mydrop.DataValueField="Serv_ID";
   mydrop.DataTextField="Serv_Name";
   mydrop.DataBind();
   mydrop.Items.Insert( 0,new ListItem("所有业务","0") );

  }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
  private void dlgOperation_EditCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
  {
   this.dlgOperation .EditItemIndex = e.Item.ItemIndex;
   dataListBind(list_Sql);
   if(e.Item.ItemType!=ListItemType.Header&&e.Item.ItemType!=ListItemType.EditItem )
   {
    Serv_Supper_ID=((Label)e.Item.FindControl("lblServSuper")).ToolTip.Trim();
    Serv_ID=((Label)e.Item.FindControl("lblServer")).ToolTip.Trim();
    Operation_id=((Label)e.Item.FindControl("lbCust_Name")).ToolTip.Trim();
 
   }
   //邦定服务商
   SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
   string sql1="select Serv_Supper_ID,Serv_Supper_Name from Comm_Serv_Supper group by Serv_Supper_ID,Serv_Supper_Name";
   System.Data.SqlClient.SqlDataAdapter mycomm1=new SqlDataAdapter(sql1,conn);
   DataSet myds1=new DataSet();
   mycomm1.Fill(myds1,"Comm_Serv_Supper");
   DropDownList mydrop1=new DropDownList();
   mydrop1=(DropDownList)dlgOperation.Items[dlgOperation.EditItemIndex].FindControl("drServ_Sup");

   mydrop1.DataSource=myds1;
   mydrop1.DataValueField="Serv_Supper_ID";
   mydrop1.DataTextField="Serv_Supper_Name";
   mydrop1.DataBind();
   mydrop1.Items.Insert( 0,new ListItem("所有服务商","0") );

   mydrop1.Items.FindByValue(Serv_Supper_ID).Selected=true;

   //邦定业务名称
   string sql="";
   if( mydrop1.SelectedValue != "0" )
    sql= "SELECT Serv_ID,Serv_Name FROM Comm_Serv WHERE Serv_Supper_ID = "+Serv_Supper_ID;
   else
    sql = "SELECT Serv_ID,Serv_Name FROM Comm_Serv";
   System.Data.SqlClient.SqlDataAdapter mycomm=new SqlDataAdapter(sql,conn);
   DataSet myds=new DataSet();
   mycomm.Fill(myds,"Comm_Serv");
   DropDownList mydrop=new DropDownList();
   mydrop=(DropDownList)dlgOperation.Items[dlgOperation.EditItemIndex].FindControl("drServ_Name");
   mydrop.DataSource=myds;
   mydrop.DataValueField="Serv_ID";
   mydrop.DataTextField="Serv_Name";
   mydrop.DataBind();
   mydrop.Items.Insert( 0,new ListItem("所有业务","0") );

   mydrop.Items.FindByValue(Serv_ID).Selected=true;

   
  }

  private void dlgOperation_SelectedIndexChanged(object sender, System.EventArgs e)
  {
     
  }
        /// <summary>
        /// 关闭
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
  private void dlgOperation_CancelCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
  {
   this.dlgOperation .EditItemIndex =-1;
   dataListBind(list_Sql);
  }

  private void dlgOperation_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e)
  {
//   if(e.Item.ItemType==ListItemType.EditItem)
//   {  
//    //邦定服务商
//    SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
//    string sql1="select Serv_Supper_ID,Serv_Supper_Name from Comm_Serv_Supper group by Serv_Supper_ID,Serv_Supper_Name";
//    System.Data.SqlClient.SqlDataAdapter mycomm1=new SqlDataAdapter(sql1,conn);
//    DataSet myds1=new DataSet();
//    mycomm1.Fill(myds1,"Comm_Serv_Supper");
//    DropDownList mydrop1=new DropDownList();
//    mydrop1=(DropDownList)e.Item.FindControl("drServ_Sup");
//    mydrop1.DataSource=myds1;
//    mydrop1.DataValueField="Serv_Supper_ID";
//    mydrop1.DataTextField="Serv_Supper_Name";
//    mydrop1.DataBind();
//    mydrop1.Items.Insert( 0,new ListItem("所有服务商","0") );
//
//    mydrop1.Items.FindByValue(Serv_Supper_ID).Selected=true;
//                this.dlitemindex=e.Item.ItemIndex;
//
//                //邦定业务名称
//    string sql="";
//    if( mydrop1.SelectedValue != "0" )
//     sql= "SELECT Serv_ID,Serv_Name FROM Comm_Serv WHERE Serv_Supper_ID = "+Serv_Supper_ID;
//    else
//     sql = "SELECT Serv_ID,Serv_Name FROM Comm_Serv";
//    System.Data.SqlClient.SqlDataAdapter mycomm=new SqlDataAdapter(sql,conn);
//    DataSet myds=new DataSet();
//    mycomm.Fill(myds,"Comm_Serv");
//    DropDownList mydrop=new DropDownList();
//    mydrop=(DropDownList)e.Item.FindControl("drServ_Name");
//    mydrop.DataSource=myds;
//    mydrop.DataValueField="Serv_ID";
//    mydrop.DataTextField="Serv_Name";
//    mydrop.DataBind();
//    mydrop.Items.Insert( 0,new ListItem("所有业务","0") );
//    
//    mydrop.Items.FindByValue(Serv_ID).Selected=true;
//
//    
//
//   }
  
  }
        /// <summary>
        /// 保存更改
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
  private void dlgOperation_UpdateCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
  {
   if(e.Item.ItemType==ListItemType.EditItem)
   {  
                string sql="update JINGZHENG_OPERATIONINFO set Serv_View='"+((TextBox)e.Item.FindControl("txServ_View")).Text.Trim()+"' where Operation_id="+int.Parse(Operation_id)+"";
    SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
    System.Data.SqlClient.SqlCommand OPeration_UpdateMycomm=new SqlCommand(sql,conn);
    try
    {
     conn.Close();
     conn.Open();
     OPeration_UpdateMycomm.ExecuteNonQuery();
    }
    catch(Exception ex)
    {
     this.Response.Write(ex);
    }
    finally
    {
     this.dlgOperation.EditItemIndex=-1;
     dataListBind(list_Sql);

    }
   }
  }
        /// <summary>
        /// 删除操作
        /// </summary>
        /// <param name="source"></param>
        /// <param name="e"></param>
  private void dlgOperation_DeleteCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
  {
   string sql="delete JINGZHENG_OPERATIONINFO  where Operation_id="+int.Parse(((Label)e.Item.FindControl("lbCust_Name")).ToolTip.Trim())+"";
   SqlConnection conn = new SqlConnection(ConfigManager.CurrentDBContext.ConnectionString);
   System.Data.SqlClient.SqlCommand OPeration_UpdateMycomm=new SqlCommand(sql,conn);
   try
   {
    conn.Close();
    conn.Open();
    OPeration_UpdateMycomm.ExecuteNonQuery();
   }
   catch(Exception ex)
   {
    this.Response.Write(ex);
   }
   finally
   {
    this.dlgOperation.EditItemIndex=-1;
    dataListBind(list_Sql);

   }
  }

  
  
 }
}

posted on 2004-09-18 18:37  feeling  阅读(1943)  评论(0编辑  收藏  举报

导航