最近 在做个项目 涉及到repeater的嵌套 和局部刷新的问题 做的好纠结啊

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="HospitalCenter.aspx.cs"
    Inherits="CREPWeb.Subjectmanage.HospitalCenter" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!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></title>
    <script type="text/javascript">
        function expandcollapse(obj, row) {
            var div = document.getElementById(obj);
            var img = document.getElementById('img' + obj);

            if (div.style.display == "none") {
                div.style.display = "block";
                if (row == 'alt') {
                    img.src = "../images/main/minus.gif";
                }
                else {
                    img.src = "../images/main/minus.gif";
                }
                img.alt = "Close to view other Customers";
            }
            else {
                div.style.display = "none";
                if (row == 'alt') {
                    img.src = "../images/main/plus.gif";
                }
                else {
                    img.src = "../images/main/plus.gif";
                }
                img.alt = "Expand to show Orders";
            }
        } 
    </script>
    <script type="text/javascript">

        function ConfirmSubmit() {
            if (confirm('您确定要删除吗?')) {
                return true;
            }
            else {
                return false;
            }
        }
   
    </script>
    
    <script src="../My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <link href="../css/common.css" rel="stylesheet" type="text/css" />
    <script src="../js/jquery-1.7.1.min.js" type="text/javascript"></script>
    <script src="../js/easyui.1.2.5/jquery.easyui.min.js" type="text/javascript"></script>
    <link href="../js/easyui.1.2.5/themes/gray/easyui.css" rel="stylesheet" type="text/css" />
    <link href="../js/easyui.1.2.5/themes/icon.css" rel="stylesheet" type="text/css" />
    <link href="../js/easyui.1.2.5/demo.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="smUser" runat="server">
    </asp:ScriptManager>
    <div>
        <table cellspacing="0" cellpadding="0" border="0" align="center" style=" 99%">
            <tr>
                <td align="left" width="160" style="font-size: 12px; color: #000000;">
                    &nbsp;课题名称:<% %>
                </td>
                <td align="right" colspan="2">
                    &nbsp;
                </td>
                <td align="right" class="GbText">
                    <asp:LinkButton ID="LinkButton2" class="easyui-linkbutton" iconCls="icon-add" runat="server"
                        OnClick="LinkButton2_Click">添加</asp:LinkButton>
                </td>
            </tr>
        </table>
    </div>
    <div>
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
            <ContentTemplate>
                <table cellspacing="0" cellpadding="0" border="0" align="center" style=" 100%">
                    <tr>
                        <td valign="middle" align="center">
                            <div style="padding-top: 5px;">
                                <!--表头begin-->
                                <table class="tableStyle" width="100%">
                                    <tr>
                                        <th style=" 10%;">
                                        </th>
                                        <th style=" 75%;">
                                            <span>分中心名字</span>
                                        </th>
                                    
                                        <th style=" 15%;">
                                            <span>删除</span>
                                        </th>
                                    </tr>
                                </table>
                                <!--表头end-->
                            </div>
                            <asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
                                <ContentTemplate>
                                    <asp:Repeater ID="dl_patient" runat="server" OnItemDataBound="dl_patient_ItemDataBound"
                                        OnItemCommand="dl_patietn_itemcommand">
                                        <HeaderTemplate>
                                            <table class="tableStyle" width="100%" id="dl_patient">
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:Label ID="lbdep" runat="server" Text='<%#Eval("hospital_id") %> ' Visible="false"></asp:Label>
                                            <tr>
                                                <td style=" 10%; text-align: center;">
                                                    <a href="javascript:expandcollapse('div<%# Eval("hospital_id") %>', 'one');">
                                                        <img id="imgdiv<%# Eval("hospital_id") %>" alt="Click to show/hide Orders for Customer <%# Eval("hospital_id") %>"
                                                            width="9px" border="0" src="../images/main/plus.gif" />
                                                    </a>
                                                </td>
                                                <td style=" 75%; text-align: center;">

                                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("hospital_name") %>'>></asp:Label>
                                                </td>
                                              
                                                <td style=" 15%; text-align: center;">
                                                    <asp:ImageButton ID="DeleteImgBtn" runat="server" ImageUrl="~/images/main/delete.gif"
                                                        AlternateText="删除" CommandName="deletebtn" CommandArgument='<%#Bind("hospital_id") %>'
                                                        OnClientClick="return ConfirmSubmit()" />
                                                </td>
                                            </tr>
                                            <tr style="text-align: center">
                                                <td align="left" colspan="4" style="text-align: left">
                                                    <div id="div<%# Eval("hospital_id") %>" style="display: none; text-align: center;
                                                         97%;">
                                                        <asp:UpdatePanel ID="UpdatePanel4" runat="server" UpdateMode="Conditional">
                                                            <ContentTemplate>
                                                                <div>
                                                                    <table cellspacing="0" cellpadding="0" border="0" align="center" style=" 99%">
                                                                        <tr>
                                                                            <td align="left" class="GbText">
                                                                                <asp:Button ID="Button1" runat="server" Text="Button" CommandName="tian" CommandArgument='<%#Bind("hospital_id") %>' />
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </div>
                                                                <table border="0" cellpadding="0" cellspacing="0" style=" 170px; text-align: left;">
                                                                    <tr>
                                                                        <td valign="middle" align="center">
                                                                            <div style="padding-top: 5px;">
                                                                                <!--表头begin-->
                                                                                <table width="800%">
                                                                                    <tr>
                                                                                        <th style=" 10%;">
                                                                                        </th>
                                                                                        <th style=" 75%;">
                                                                                            <span>科室名称</span>
                                                                                        </th>
                                                                                      
                                                                                        <th style=" 15%;">
                                                                                            <span>删除</span>
                                                                                        </th>
                                                                                </table>
                                                                                <!--表头end-->
                                                                            </div>
                                                                            <asp:Repeater ID="dl_patient1" runat="server" OnItemDataBound="dl_patient_ItemDataBound1"
                                                                                OnItemCommand="dl_patietn_itemcommand2">
                                                                                <HeaderTemplate>
                                                                                    <table width="800%" id="dl_patient">
                                                                                </HeaderTemplate>
                                                                                <ItemTemplate>
                                                                                    <asp:Label ID="lbdep1" runat="server" Text='<%#Eval("dept_code") %> ' Visible="false"></asp:Label>
                                                                                    <asp:Label ID="Label3" runat="server" Text='<%#Eval("hospital_id") %> ' Visible="false"></asp:Label>
                                                                                    <tr>
                                                                                        <td style=" 10%; text-align: center;">
                                                                                            <a href="javascript:expandcollapse('div<%# Eval("dept_code") %>', 'one');">
                                                                                                <img id="imgdiv<%# Eval("dept_code") %>" alt="Click to show/hide Orders for Customer <%# Eval("dept_code") %>"
                                                                                                    width="9px" border="0" src="../images/main/plus.gif" />
                                                                                            </a>
                                                                                        </td>
                                                                                        <td style=" 75%; text-align: center;">
                                                                                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("dept_name") %>'>></asp:Label>
                                                                                        </td>
                                                                                        
                                                                                        <td style=" 15%; text-align: center;">
                                                                                            <asp:ImageButton ID="DeleteImgBtn" runat="server" ImageUrl="~/images/main/delete.gif"
                                                                                                AlternateText="删除" CommandName="deletebtn" CommandArgument='<%# Eval("dept_code")+","+Eval("hospital_id")%>'
                                                                                                OnClientClick="return ConfirmSubmit()" />
                                                                                        </td>
                                                                                    </tr>
                                                                                    <tr>
                                                                                        <td align="left" colspan="4" style="text-align: left">
                                                                                            <div id="div<%# Eval("dept_code") %>" style="display: none; text-align: center;  100%;">
                                                                                                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                                                                                    <ContentTemplate>
                                                                                                        <div>
                                                                                                            <table cellspacing="0" cellpadding="0" border="0" align="center" style=" 99%">
                                                                                                                <tr>
                                                                                                                    <td align="left" class="GbText">
                                                                                                                        <asp:Button ID="Button2" runat="server" Text="Button" CommandName="tian" CommandArgument='<%# Eval("dept_code")+","+Eval("hospital_id")%>'/>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                            </table>
                                                                                                        </div>
                                                                                                        <table border="0" cellpadding="0" cellspacing="0" style=" 170px; text-align: left;">
                                                                                                            <tr>
                                                                                                                <td valign="middle" align="center">
                                                                                                                    <div style="padding-top: 5px;">
                                                                                                                        <!--表头begin-->
                                                                                                                        <table width="800%">
                                                                                                                            <tr>
                                                                                                                                <th style=" 35%;">
                                                                                                                                    <span>姓名</span>
                                                                                                                                </th>
                                                                                                                                <th style=" 35%;">
                                                                                                                                    <span>性别</span>
                                                                                                                                </th>
                                                                                                                                <th style=" 15%;">
                                                                                                                                    <span>编辑</span>
                                                                                                                                </th>
                                                                                                                                <th style=" 15%;">
                                                                                                                                    <span>删除</span>
                                                                                                                                </th>
                                                                                                                        </table>
                                                                                                                        <!--表头end-->
                                                                                                                    </div>
                                                                                                                    <asp:Repeater ID="dl_patient2" runat="server">
                                                                                                                        <HeaderTemplate>
                                                                                                                            <table width="800%" id="dl_patient">
                                                                                                                        </HeaderTemplate>
                                                                                                                        <ItemTemplate>
                                                                                                                            <asp:HiddenField ID="HiddenField3" runat="server" Value='<%# Bind("user_id") %>' />
                                                                                                                            <tr>
                                                                                                                                <td style=" 35%; text-align: center;">
                                                                                                                                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("user_name") %>'></asp:Label>
                                                                                                                                </td>
                                                                                                                                <td style=" 35%; text-align: center;">
                                                                                                                                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("user_name") %>'></asp:Label>
                                                                                                                                </td>
                                                                                                                                <td style=" 15%; text-align: center;">
                                                                                                                                    <asp:ImageButton ID="EditImgBtn" runat="server" AlternateText="编辑" CommandArgument='<%#Bind("user_id") %>'
                                                                                                                                        CommandName="editbtn" ImageUrl="~/images/main/edit.gif" />
                                                                                                                                </td>
                                                                                                                                <td style=" 15%; text-align: center;">
                                                                                                                                    <asp:ImageButton ID="DeleteImgBtn" runat="server" ImageUrl="~/images/main/delete.gif"
                                                                                                                                        AlternateText="删除" CommandName="deletebtn" CommandArgument='<%#Bind("user_id") %>'
                                                                                                                                        OnClientClick="return ConfirmSubmit()" />
                                                                                                                                </td>
                                                                                                                            </tr>
                                                                                                                        </ItemTemplate>
                                                                                                                        <FooterTemplate>
                                                                                                                            </table>
                                                                                                                        </FooterTemplate>
                                                                                                                    </asp:Repeater>
                                                                                                                </td>
                                                                                                            </tr>
                                                                                                        </table>
                                                                                                    </ContentTemplate>
                                                                                                </asp:UpdatePanel>
                                                                                            </div>
                                                                                        </td>
                                                                                    </tr>
                                                                                </ItemTemplate>
                                                                                <FooterTemplate>
                                                                                    </table>
                                                                                </FooterTemplate>
                                                                            </asp:Repeater>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </ContentTemplate>
                                                        </asp:UpdatePanel>
                                                    </div>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                        <FooterTemplate>
                                            </table>
                                        </FooterTemplate>
                                    </asp:Repeater>
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                </table>
                <div class="footer">
                    <webdiyer:AspNetPager ID="AspNetPager1" runat="server" AlwaysShow="True" CustomInfoSectionWidth="15%"
                        CustomInfoTextAlign="Right" FirstPageText="第一页" HorizontalAlign="Right" LastPageText="末一页"
                        NavigationButtonType="Image" NextPageText="后一页" PageIndexBoxType="TextBox" PagingButtonSpacing="8px"
                        PrevPageText="前一页" ShowCustomInfoSection="Right" ShowPageIndexBox="Always" TextAfterPageIndexBox=""
                        UrlPaging="false" TextBeforePageIndexBox="跳到第" OnPageChanged="AspNetPager1_PageChanged"
                        CustomInfoHTML="共%PageCount%页,当前为第%CurrentPageIndex%页">
                    </webdiyer:AspNetPager>
                </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>
    <asp:UpdatePanel ID="upAddUser" runat="server">
        <ContentTemplate>
            <asp:Panel ID="p1" runat="server" Style="display: none">
                <asp:Panel ID="p2" runat="server">
                    <table border="0" cellpadding="0" cellspacing="0" style=" 350px; border: #6B97C1 1px solid;
                        background-color: #ffffff;">
                        <tr>
                            <td style="height: 30px;  310px; background: url(../images/main/pupop_bg.png) repeat-x 0 0;">
                                <span style="font-size: 13px; color: #ffffff; font-weight: bold;">&nbsp;<%--<%=Msg_Title %>--%></span></td>
                            <td valign="top" style=" 40px; height: 30px; background: url(../images/main/pupop_bg.png) repeat-x 0 0;">
                                <input type="image" src="../images/main/c1.gif" onmouseover="this.src='../images/main/c1.gif'"
                                    onmouseout="this.src='../images/main/c1.gif'" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center" valign="middle">
                                <table class="tableStyle" border="0" cellpadding="0" cellspacing="0" style=" 340px;">
                                    <tr>
                                        <td class="tdLeft">
                                            分中心名称:
                                        </td>
                                        <td class="tdRight">
                                            &nbsp;<asp:DropDownList ID="DropDownList1" runat="server">
                                            </asp:DropDownList>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="right" style="background-color: #f3f3f3; height: 35px; border-top: #e0e0e0 1px solid">
                                <asp:Button ID="btnAddUserOK" runat="server" Text="确定" OnClick="btnAddUserOK_Click" />
                                <asp:Button ID="btnUpdateOK" Visible="false" runat="server" Text="确定修改" />&nbsp;
                            </td>
                        </tr>
                    </table>

                </asp:Panel>
            </asp:Panel>
            <input id="hid1" type="hidden" runat="server" />
            <cc1:ModalPopupExtender ID="mpeAddUser" runat="server" BackgroundCssClass="modalBackground"
                TargetControlID="hid1" PopupControlID="p1" DropShadow="false" Drag="true" PopupDragHandleControlID="p2">
            </cc1:ModalPopupExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdatePanel ID="UpdatePanel5" runat="server">
        <ContentTemplate>
            <asp:Panel ID="Panel3" runat="server" Style="display: none">
                <asp:Panel ID="Panel4" runat="server">
                    <table border="0" cellpadding="0" cellspacing="0" style=" 350px; border: #6B97C1 1px solid;
                        background-color: #ffffff;">
                        <tr>
                            <td style="height: 30px;  310px; background: url(../images/main/pupop_bg.png) repeat-x 0 0;">
                                <span style="font-size: 13px; color: #ffffff; font-weight: bold;">&nbsp;<%--<%=Msg_Title %>--%></span></td>
                            <td valign="top" style=" 40px; height: 30px; background: url(../images/main/pupop_bg.png) repeat-x 0 0;">
                                <input type="image" src="../images/main/c1.gif" onmouseover="this.src='../images/main/c1.gif'"
                                    onmouseout="this.src='../images/main/c1.gif'" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center" valign="middle">
                                <table class="tableStyle" border="0" cellpadding="0" cellspacing="0" style=" 340px;">
                                    <tr>
                                        <td class="tdLeft">
                                            科室名称:
                                        </td>
                                        <td class="tdRight">
                                            &nbsp;<asp:DropDownList ID="DropDownList2" runat="server">
                                            </asp:DropDownList>
                                            </div>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="right" style="background-color: #f3f3f3; height: 35px; border-top: #e0e0e0 1px solid">
                                <asp:Button ID="Button3" runat="server" Text="确定" OnClick="btnAddUserOK_Click1" />
                                <asp:Button ID="Button4" Visible="false" runat="server" Text="确定修改" />&nbsp;
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </asp:Panel>
            <input id="Hidden1" type="hidden" runat="server" />
            <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" BackgroundCssClass="modalBackground"
                TargetControlID="Hidden1" PopupControlID="panel3" DropShadow="false" Drag="true"
                PopupDragHandleControlID="panel4">
            </cc1:ModalPopupExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdatePanel ID="UpdatePanel6" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:Panel ID="Panel1" runat="server" Style="display:none ">
                <asp:Panel ID="Panel2" runat="server">
                    <table border="0" cellpadding="0" cellspacing="0" style=" 450px; border: #6B97C1 1px solid;
                        background-color: #ffffff;">
                        <tr>
                            <td style="height: 30px;  310px; background: url(../images/main/pupop_bg.png) repeat-x 0 0;">
                                <span style="font-size: 13px; color: #ffffff; font-weight: bold;">&nbsp;<%--<%=Msg_Title %>--%></span></td>
                            <td valign="top" style=" 40px; height: 30px; background: url(../images/main/pupop_bg.png) repeat-x 0 0;">
                                <input type="image" src="../images/main/c1.gif" onmouseover="this.src='../images/main/c1.gif'"
                                    onmouseout="this.src='../images/main/c1.gif'" />
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="center" valign="middle">
                                <table class="tableStyle" border="0" cellpadding="0" cellspacing="0" style=" 450px;">
                                    <tr>
                                        <td class="tdLeft">
                                            登录名 :
                                        </td>
                                        <td class="tdRight">
                                            <asp:TextBox ID="txtLoginName" runat="server" Width="200px" MaxLength="50"></asp:TextBox>
                                            <asp:Label ID="label2" runat="server" Visible="false" ForeColor="red">登录名已存在,请重新输入</asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="tdLeft">
                                            密码 :
                                        </td>
                                        <td class="tdRight">
                                            <asp:TextBox ID="firstpassword" runat="server" Width="200px" MaxLength="50" TextMode="Password"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="tdLeft">
                                            确认密码 :
                                        </td>
                                        <td class="tdRight">
                                            <asp:TextBox ID="secondpassword" runat="server" Width="200px" MaxLength="50" TextMode="Password"></asp:TextBox>
                                            <asp:Label ID="label1" runat="server" Visible="false" ForeColor="red">两次密码不一样,请重新确认</asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td class="tdLeft">
                                            姓名 :
                                        </td>
                                        <td class="tdRight">
                                            <asp:TextBox ID="name" runat="server" Width="200px" MaxLength="50"></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td  class="tdLeft">
                                            备注:
                                        </td>
                                        <td class="tdRight">
                                            <asp:TextBox ID="TextBox1" runat="server" Width="200px" MaxLength="50" TextMode="MultiLine"></asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2" align="right" style="background-color: #f3f3f3; height: 35px; border-top: #e0e0e0 1px solid">
                                <asp:Button ID="Button5" runat="server" Text="确定" onclick="Button5_Click" />
                                <asp:Button ID="Button6" Visible="false" runat="server" Text="确定修改" />&nbsp;
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
              
            </asp:Panel>
            
            <input id="Hidden2" type="hidden" runat="server" />
            <cc1:ModalPopupExtender ID="ModalPopupExtender2" runat="server" BackgroundCssClass="modalBackground"
                TargetControlID="Hidden2" PopupControlID="panel1" DropShadow="false" Drag="true"
                PopupDragHandleControlID="panel2">
            </cc1:ModalPopupExtender>
        </ContentTemplate>
    </asp:UpdatePanel>
      <asp:HiddenField ID="HiddenField1" runat="server" />
    </form>
</body>
</html>

后台部分代码

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Reflection;
using CREPWeb.Common;

namespace CREPWeb.Subjectmanage
{


    public partial class HospitalCenter : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                centerbind();
                droplistbind();

            }

        }
        public void centerbind()
        {
            string subjectid = Request.QueryString["pid"].ToString();
            string sql = "select t.hospital_name, t.hospital_id from drr_hospital_dict t, drr_sub_centers_dict o, drr_subject_dict m where t.hospital_id = o.hospital_id and o.subject_id = m.subject_id and m.subject_id='" + subjectid + "'";
           
            DataTable dt = DbHelperOracle.GetDataTable(sql);
            int Sqlcount = dt.Rows.Count;//总记录数
            this.AspNetPager1.RecordCount = Sqlcount;
            AspNetPager1.AlwaysShow = true;
            int pageSize = this.AspNetPager1.PageSize = 10;//每页记录数
            int startIndex = (this.AspNetPager1.CurrentPageIndex - 1) * pageSize + 1;//每页最开始索引
            int startindex1 = startIndex + 10;
            string sql2 = "select * from(select row_number() over (order by t.hospital_id desc) x,t.hospital_name, t.hospital_id from drr_hospital_dict t, drr_sub_centers_dict o, drr_subject_dict m where t.hospital_id = o.hospital_id and o.subject_id = m.subject_id and m.subject_id='" + subjectid + "')a where a.x>='" + startIndex + "'and a.x<'" + startindex1 + "'";
            DataTable dm = DbHelperOracle.GetDataTable(sql2);
            dl_patient.DataSource = dm;
            dl_patient.DataBind();
        }
        public void droplistbind()
        {
            string sql = "select t.*, t.rowid from drr_hospital_dict t";
            DataTable dt = DbHelperOracle.GetDataTable(sql);
            DrrClass.BindControl(DropDownList1, dt, "hospital_name", "hospital_id");


        }
        protected void dl_patient_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                string subjectid = Request.QueryString["pid"].ToString();
                Repeater rephangdao = e.Item.FindControl("dl_patient1") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                string depid = rowv["hospital_id"].ToString(); //获取填充子类的id 
                string sql = "select t.* from drr_dept_dict t,drr_subject_dict m,drr_sub_dept o where t.dept_code=o.dept_code and o.subject_id=m.subject_id and t.hospital_id ='" + depid.ToString() + "' and m.subject_id='"+subjectid+"'";
                DataTable dt = DbHelperOracle.GetDataTable(sql);
                DataColumn dc =new DataColumn();
                rephangdao.DataSource = dt;
                rephangdao.DataBind();
            }

        }
        protected void dl_patient_ItemDataBound1(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Repeater repbanci = e.Item.FindControl("dl_patient2") as Repeater;//找到里层的repeater对象
                DataRowView rowv = (DataRowView)e.Item.DataItem;//找到分类Repeater关联的数据项 
                string depid = rowv["dept_code"].ToString(); //获取填充子类的id 
                string sql = "select t.*, t.rowid from drr_system_user t where t.dept_code='" + depid + "'";
                DataTable dt = DbHelperOracle.GetDataTable(sql);

                repbanci.DataSource = dt;
                repbanci.DataBind();

            }

        }
        protected void dl_patietn_itemcommand2(object source, RepeaterCommandEventArgs e)
        {
            string[] arg;
         
            if (e.CommandName == "tian")
            {

                DataRowView rowv = (DataRowView)e.Item.DataItem;

                 arg = e.CommandArgument.ToString().Split(',');
                ViewState["id"] = arg[0];
                ViewState["hospitalid"] = arg[1];
                txtLoginName.Text = "";
                firstpassword.Text = "";
                name.Text = "";
                TextBox1.Text = "";
              
                this.ModalPopupExtender2.Show();


            }
            else if (e.CommandName == "deletebtn")
            {
               arg = e.CommandArgument.ToString().Split(',');
                string dept_code = arg[0];
                string hospital_id = arg[1];
                string sql1 = "delete from drr_sub_dept where drr_sub_dept.hospital_id='" + hospital_id + "' and drr_sub_dept.subject_id='" + Request.QueryString["pid"].ToString() + "' and drr_sub_dept.dept_code='" + dept_code + "'";
                DbHelperOracle.ExecuteOracle(sql1);
                string subjectid = Request.QueryString["pid"].ToString();
               
                Repeater rephangdao = (Repeater)source;
                string sql = "select t.* from drr_dept_dict t,drr_subject_dict m,drr_sub_dept o where t.dept_code=o.dept_code and o.subject_id=m.subject_id and t.hospital_id ='" + hospital_id + "' and m.subject_id='" + subjectid + "'";
                DataTable dt = DbHelperOracle.GetDataTable(sql);
                rephangdao.DataSource = dt;
                rephangdao.DataBind();
            }

        }
        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            centerbind();
        }
        protected void dl_patietn_itemcommand(object source, RepeaterCommandEventArgs e)
        {
            string id = "";
            if (e.CommandName == "tian")
            {

                id = e.CommandArgument.ToString();
              
                string sql = "select * from  drr_dept_dict where drr_dept_dict.hospital_id='"+id+"'";
                DataTable dt = DbHelperOracle.GetDataTable(sql);
                DrrClass.BindControl(DropDownList2, dt, "dept_name", "dept_code");

                ViewState["id"] = id;
                this.ModalPopupExtender1.Show();

            }
            else if (e.CommandName == "deletebtn")
            {
                id = e.CommandArgument.ToString();
                List<string> strdete = new List<string>();
                string sql = "delete from  drr_sub_centers_dict  where drr_sub_centers_dict.hospital_id ='" + id + "' and drr_sub_centers_dict.subject_id='" + Request.QueryString["pid"].ToString() + "'";
                string sql1 = "delete from drr_sub_dept where drr_sub_dept.hospital_id='" + id + "' and drr_sub_dept.subject_id='" + Request.QueryString["pid"].ToString() + "'";
                strdete.Add(sql);
                strdete.Add(sql1);
                DbHelperOracle.ExecuteOracleTran(strdete);
                centerbind();
                
            
            }
        }
        protected void btnAddUserOK_Click(object sender, EventArgs e)
        {
            string subjectid = Request.QueryString["pid"].ToString();
            string sql = "insert into drr_sub_centers_dict (subject_id,hospital_id )VALUES('"+subjectid+"','" + DropDownList1.Text + "')";
            DbHelperOracle.ExecuteSql(sql);
            centerbind();
            UpdatePanel2.Update();
            //for (int i = 0; i < dl_patient.Items.Count; i++)
            //{
            //    UpdatePanel up = ((UpdatePanel)dl_patient.Items[i].FindControl("UpdatePanel4"));
            //    up.Update();

            //}
        }
        protected void LinkButton2_Click(object sender, EventArgs e)
        {
            this.mpeAddUser.Show();

        }
        protected void btnAddUserOK_Click1(object sender, EventArgs e)
        {

            string hospitalid = ViewState["id"].ToString();
            string subjectid = Request.QueryString["pid"].ToString();
            string sql = "insert  into drr_sub_dept (subject_id,hospital_id,dept_code) values('" + subjectid + "','" + hospitalid + "','" + DropDownList2.Text + "')";
            DbHelperOracle.ExecuteSql(sql);

            for (int i = 0; i < dl_patient.Items.Count; i++)
            {
                Label label1 = ((Label)dl_patient.Items[i].FindControl("lbdep"));
                if (label1.Text == hospitalid)
                {
                Repeater re = ((Repeater)dl_patient.Items[i].FindControl("dl_patient1"));
                string sqll = "select t.* from drr_dept_dict t,drr_subject_dict m,drr_sub_dept o where t.dept_code=o.dept_code and o.subject_id=m.subject_id and t.hospital_id ='" + hospitalid.ToString() + "' and m.subject_id='" + subjectid + "'";
                DataTable dt = DbHelperOracle.GetDataTable(sqll);
                re.DataSource = dt;
               
                re.DataBind();
                UpdatePanel up = ((UpdatePanel)dl_patient.Items[i].FindControl("UpdatePanel4"));
                up.Update();
                }

            }
        
        }
        public int AutoNumberString(int firstid)
        {
           
            int num;
            string str1 = "select max(t.user_id) as max  from drr_system_user  t";
            string str2 = "select Count(*)as count from drr_system_user t";
            DataTable dm = DbHelperOracle.GetDataTable(str2);
            DataTable dt = DbHelperOracle.GetDataTable(str1);
            if (Convert.ToInt32(dm.Rows[0]["count"]) == 0)
            {
                num = firstid;
            }
            else
            {
                num = Convert.ToInt32(dt.Rows[0]["max"]) + 1;
            }
            return num;
        }
        protected void Button5_Click(object sender, EventArgs e)
        {
            string deptcode = ViewState["id"].ToString();
            if (txtLoginName.Text == "" || firstpassword.Text == "" || name.Text == "")
            {
                ClientScript.RegisterStartupScript(Page.GetType(), "", "<script>alert('你输入的信息不全);</script>");
               
            }
            else
            {
                string str = "select t.*, t.rowid from drr_system_user t where t.user_name='" + txtLoginName.Text.Trim().ToString() + "'";
                DataTable dt = DbHelperOracle.GetDataTable(str);
                if (dt.Rows.Count > 0)
                {
                    label2.Visible = true;
                    this.ModalPopupExtender2.Show();

                }
                else
                {
                    if (firstpassword.Text != secondpassword.Text)
                    {
                        label1.Visible = true;
                        this.ModalPopupExtender2.Show();
                    }
                    else
                    {
                        DateTime dtime = DateTime.Now;

                        int userid = AutoNumberString(1);
                        List<string> listsql = new List<string>();
                        string usrsql = "insert into drr_system_user(user_id,user_name,real_name,dept_code,remarks,TIMESTAMP)values('" + userid + "','" + txtLoginName.Text.Trim().ToString() + "','" + name.Text.Trim().ToString() + "','" + deptcode + "','" + TextBox1.Text.Trim().ToString() + "',to_date('" + dtime + "','YYYY-MM-DD HH24:MI:SS'))";
                        string passwordsql = "insert into drr_system_user_password (user_id,password,TIMESTAMP)values('" + userid + "','" + firstpassword.Text.Trim().ToString() + "',to_date('" + dtime + "','YYYY-MM-DD HH24:MI:SS'))";
                        string statesql = "insert into drr_system_user_login_state (user_id,online_flag,TIMESTAMP)values('" + userid + "','0',to_date('" + dtime + "','YYYY-MM-DD HH24:MI:SS'))";
                        listsql.Add(usrsql);
                        listsql.Add(passwordsql);
                        listsql.Add(statesql);
                        DbHelperOracle.ExecuteOracleTran(listsql);
                       
                    }

                }

            }
            for (int i = 0; i < dl_patient.Items.Count; i++)
            {
                Label label6 = ((Label)dl_patient.Items[i].FindControl("lbdep"));
                if (label6.Text == ViewState["hospitalid"].ToString())
                {
                    Repeater re = ((Repeater)dl_patient.Items[i].FindControl("dl_patient1"));
                    for (int j = 0; j < re.Items.Count; j++)
                    {

                        Label hospita = ((Label)re.Items[j].FindControl("lbdep1"));
                        if (hospita.Text == ViewState["id"].ToString())
                        {

                            Repeater rm = ((Repeater)re.Items[j].FindControl("dl_patient2"));
                            string sqll = "select t.*, t.rowid from drr_system_user t where t.dept_code='" + ViewState["id"].ToString() + "'"; ;
                            DataTable dt = DbHelperOracle.GetDataTable(sqll);
                            rm.DataSource = dt;

                            rm.DataBind();
                            UpdatePanel mp= ((UpdatePanel)re.Items[i].FindControl("UpdatePanel1"));
                            mp.Update();
                            UpdatePanel6.Update();
                        }
                    
                    }
                }

            }

        }
     }

}
原文地址:https://www.cnblogs.com/haihang/p/2950255.html