Repeater控件代码: <table width="800px"  cellpadding="0" cellspacing="0"  >
       <tr style=" background-color:#A9A9A9; height:25px; color:White "  align="center"> 
             
       <td  style=" width:50px; font-size:15px">类型ID</td>
        <td style=" width:2px; background-color:White"></td>
    <td style=" width:144px; font-size:15px">专题栏目类型名称</td>
    <td style=" width:2px; background-color:White"></td>  
    <td style=" width:200px; font-size:15px">自媒体专题栏目名称</td>
    <td style=" width:2px; background-color:White"></td>
    <td colspan="5" style=" width:400px; font-size:15px" >基本功能操作</td>    
  </tr></table>
  
<asp:Repeater ID="dglist" runat="server">
<ItemTemplate>
<table width="800px"  cellpadding="0" cellspacing="0"  style="font-size:15px">
<tr style="background-color:#F8F8FF; height:25px"  align="center" >

<td style=" width:50px">
<A2:A2Label ID="lblID" runat="server"  Text="lblID" />
</td>
 <td style=" width:2px; background-color:White"></td>
<td style=" width:144px" >
<A2:A2Label ID="lblClassTypeName" runat="server"  Text="lblClassTypeName" />
</td>
<td style=" width:2px; background-color:White"></td>
<td style=" width:200px">
<A2:A2Label ID="lblClassName" runat="server"  Text="lblClassName" />
</td>
<td style=" width:2px; background-color:White"></td>
<td align="center" style="width:45px">
     <asp:HyperLink ID="hlkModify" runat="server" Text="修改"></asp:HyperLink>
</td>
<td style=" width:10px"></td>
<td style=" width:45px">
<asp:LinkButton ID="lbnDel" runat="server" Text="删除" ></asp:LinkButton>
</td>
<td style=" width:10px;"></td>
<td align="center" style=" width:145px">
<asp:DropDownList ID="dplModifyUp" runat="server"  >
</asp:DropDownList>
<asp:Button ID="btModifyUp" runat="server" Text="修改" ></asp:Button>
</td>
<td align="center" style=" width:145px">
<asp:DropDownList ID="dplModifyDown" runat="server"  >
</asp:DropDownList>
<asp:Button ID="btModifyDown" runat="server" Text="修改" ></asp:Button>
</td>
</tr>
<tr> 
<td style="background-color:White; height:2px" colspan="20" ></td>
</tr>

</table>
</ItemTemplate>
</asp:Repeater>
服务器代码中如何获取DropDownList的所选值呢???

解决方案 »

  1.   

    在ItemDataBound事件中findecontrol这个drp然后取值
      

  2.   

    主要是获取到DropDownList控件。可以用DropDownList ddl = Page.FindControl(ID) as DropDownList,
      

  3.   

    参考下吧,希望对你有帮助。
    我的博客 程序员日记 http://www.ideaext.com 欢迎交流
         /// <summary>
            /// 更新数据
            /// </summary>
            /// <param name="e"></param>
            private void myUpdate(System.Web.UI.WebControls.DataGridCommandEventArgs e)
            {
                int myIndex = e.Item.ItemIndex;            String orderid = ((Label)e.Item.FindControl("orderid")).Text.Trim().ToString();
                String paymethod = "";            DropDownList reason = (DropDownList)this.myGrid.Items[myIndex].FindControl("ddlmethod");            if (reason.SelectedIndex == 0)
                {
                    this.Response.Write("<script>alert('Choose a payment first!');history.back();</script>");
                    this.Response.End();
                }
                else
                {
                    paymethod = reason.Text;                string sql = "";
                    ////求取当前键值
                    //string myKeyid = this.myGrid.DataKeys[myIndex].ToString();
                    try
                    {
                        sql = "update orderhead set syspaymethod=" + "'" + paymethod + "'" + "," + "orderstatus='Paid',paydate=now() where orderid=" + "'" + orderid + "'";
                        if (!nd.updateOrderStatus(sql))
                        {
                            this.Response.Write("<script>alert('Update failed!');history.back();</script>");
                        }
                    }
                    catch
                    {
                        this.Response.Write("<script>alert('Sorrry System error!');history.back();</script>");
                        this.Response.End();
                    }
                    finally
                    {
                        //撤销编辑状态
                        this.myGrid.EditItemIndex = -1;
                        //重新绑定
                        this.myGridBind();
                    }
                }
            }
      

  4.   

    if (e.Item.ItemType == ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem)
            {
                DropDownList myDrop = e.Item.FindControl("drpList") as DropDownList;
           }
    protected void myDrop_SelectedIndexChanged(object sender,EventArgs e)
        {
            Response.Write(((DropDownList)sender).SelectedIndex.ToString());
        }