aspx文件<table width="100%" border="0" cellpadding="3" cellspacing="1" class="MainTable" id="BoardTable" >
<tr class="MainTableHeader">
<td colspan="5">版块管理</td>
</tr>
<tr>
<td colspan="5">
<asp:Label ID="AddActLink" runat="server" Text="Label"></asp:Label> <asp:Label ID="RepairSortLink" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td colspan="5" height="4px" ></td>
</tr>
<asp:Repeater ID="BoardRepeater" runat="server" onitemcommand="BoardRepeater_ItemCommand" >
<HeaderTemplate>
<tr>
<td>基本操作</td>
<td>+ 版块名称</td>
<td>类型</td>
<td>高级操作</td>
<td>动作</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td ><asp:Label ID="LowActLink" runat="server">Label</asp:Label></td>
<td ><asp:Label ID="LabelSplitStr" runat="server" >Label</asp:Label><asp:TextBox ID="BoardActLink" runat="server"></asp:TextBox><asp:HiddenField ID="LbBoardId" runat="server" /> </td>
<td ><asp:DropDownList ID="ddlKindModel" runat="server" ></asp:DropDownList><asp:DropDownList ID="ddlKindNameId" runat="server" ></asp:DropDownList></td>
<td ><asp:Label ID="HighActLink" runat="server">Label</asp:Label></td>
<td ><asp:Button ID="UpdateButton" runat="server" Text="更 新" CommandName ="UpdateButton_Click"/></td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td colspan="5" height="4px" ></td>
</tr>
</table>CS文件
protected void BoardRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("UpdateButton_Click"))
{
TextBox BoardActLink = (TextBox)e.Item.FindControl("BoardActLink");//OK可以找到值
HiddenField LbBoardId = (HiddenField)e.Item.FindControl("LbBoardId");//OK可以找到值
DropDownList ddlKindModel = (DropDownList)e.Item.FindControl("ddlKindModel"); //DropDownList就是不行
//DropDownList ddlKindNameId = (DropDownList)e.Item.FindControl("ddlKindNameId");
ModBoard = BLL_Admin_Board.GetBoardModel("BoardId=" +Convert.ToInt32(LbBoardId.Value));
ModBoard.KindModel = Convert.ToInt32(ddlKindModel.SelectedValue);
//ModBoard.KindNameId = Convert.ToInt32(ddlKindNameId.Text);
ModBoard.BoardName = BoardActLink.Text;
BLL_Admin_Board.BoardEdit(ModBoard);
Response.Write(" <script> alert( '" + ddlKindModel.Text + " '); </script> ");
}
} DropDownList ddlKindModel = (DropDownList)e.Item.FindControl("ddlKindModel"); //DropDownList就是不行老是count为0
<tr class="MainTableHeader">
<td colspan="5">版块管理</td>
</tr>
<tr>
<td colspan="5">
<asp:Label ID="AddActLink" runat="server" Text="Label"></asp:Label> <asp:Label ID="RepairSortLink" runat="server" Text="Label"></asp:Label>
</td>
</tr>
<tr>
<td colspan="5" height="4px" ></td>
</tr>
<asp:Repeater ID="BoardRepeater" runat="server" onitemcommand="BoardRepeater_ItemCommand" >
<HeaderTemplate>
<tr>
<td>基本操作</td>
<td>+ 版块名称</td>
<td>类型</td>
<td>高级操作</td>
<td>动作</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td ><asp:Label ID="LowActLink" runat="server">Label</asp:Label></td>
<td ><asp:Label ID="LabelSplitStr" runat="server" >Label</asp:Label><asp:TextBox ID="BoardActLink" runat="server"></asp:TextBox><asp:HiddenField ID="LbBoardId" runat="server" /> </td>
<td ><asp:DropDownList ID="ddlKindModel" runat="server" ></asp:DropDownList><asp:DropDownList ID="ddlKindNameId" runat="server" ></asp:DropDownList></td>
<td ><asp:Label ID="HighActLink" runat="server">Label</asp:Label></td>
<td ><asp:Button ID="UpdateButton" runat="server" Text="更 新" CommandName ="UpdateButton_Click"/></td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td colspan="5" height="4px" ></td>
</tr>
</table>CS文件
protected void BoardRepeater_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("UpdateButton_Click"))
{
TextBox BoardActLink = (TextBox)e.Item.FindControl("BoardActLink");//OK可以找到值
HiddenField LbBoardId = (HiddenField)e.Item.FindControl("LbBoardId");//OK可以找到值
DropDownList ddlKindModel = (DropDownList)e.Item.FindControl("ddlKindModel"); //DropDownList就是不行
//DropDownList ddlKindNameId = (DropDownList)e.Item.FindControl("ddlKindNameId");
ModBoard = BLL_Admin_Board.GetBoardModel("BoardId=" +Convert.ToInt32(LbBoardId.Value));
ModBoard.KindModel = Convert.ToInt32(ddlKindModel.SelectedValue);
//ModBoard.KindNameId = Convert.ToInt32(ddlKindNameId.Text);
ModBoard.BoardName = BoardActLink.Text;
BLL_Admin_Board.BoardEdit(ModBoard);
Response.Write(" <script> alert( '" + ddlKindModel.Text + " '); </script> ");
}
} DropDownList ddlKindModel = (DropDownList)e.Item.FindControl("ddlKindModel"); //DropDownList就是不行老是count为0
{ BindData();}
<asp:repeater id="Repeater1" runat="server" onitemdatabound="Repeater1_ItemDataBound">
<itemtemplate>
<div>
<asp:dropdownlist id="ddl" autopostback="true" onselectedindexchanged="myDrop_SelectedIndexChanged" runat="server"> </asp:dropdownlist>
</div>
</itemtemplate>
</asp:repeater> protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item||e.Item.ItemType==ListItemType.AlternatingItem||e.Item.ItemType==ListItemType.EditItem)
{
DropDownList myDrop = e.Item.FindControl("ddl") as DropDownList;
}
} protected void myDrop_SelectedIndexChanged(object sender,EventArgs e)
{
Response.Write(((DropDownList)sender).SelectedIndex.ToString());
}
要是点 "更新" 这个按钮时才触发去找这行所有控制的值<item>
Texbox Texbox DropDownList 按钮
</item>
点按钮时该行的TextBoxt可以,但DropDownList获取不到值。