formview空间挺合意的,但是它的显示无法控制,如果,想要的不是分页效果,而是全部列表出来的效果

解决方案 »

  1.   

    repeater是轻量级的数据绑定控件,最大的功能就是重复生成行(听名字就知道了),如果要在repeater控件生成的列表中添加插入,删除,修改操作,你可以在被repeater控件所repeat的标签(如一个tr)中加入相关功能就可以了。例如:(手写代码我不能全部写出来,只做个大概)
    <RepeateItem>
    <tr><td>......</td><td>修改</td><td>插入</td><td>删除</td></tr>
    </RepeateItem>
    你可以在相关的td中使用ajax来实现相关的插入,删除,修改操作。
      

  2.   

    给你参考一下
     <table width="800" style="text-align: center;" border="1" cellpadding="5" cellspacing="0">
                    <tr>
                        <th width="100">
                            房间号</th>
                        <th width="110">
                            客户类型</th>
                        <th width="90">
                            床位数</th>
                        <th width="90">
                            客人数</th>
                        <th width="90">
                            状态</th>
                        <th width="160">
                            描述</th>
                        <th width="80">
                            修改
                        </th>
                        <th width="80">
                            删除
                        </th>
                    </tr>
     <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand"
            OnItemDataBound="Repeater1_ItemDataBound">
                       <ItemTemplate>
                <tr id="row" runat="server" >
                    <td>
                        <%# Eval("number")%>
                    </td>
                    <td>
                        <%# Eval("type.typename")%>
                    </td>
                    <td>
                        <%# Eval("bebnumber")%>
                    </td>
                    <td>
                        <%# Eval("guestnumber")%>
                    </td>
                    <td>
                        <%# Eval("state.StateName")%>
                    </td>
                    <td>
                        <%# Eval("description")%>
                    </td>
                    <td width="80">
                        <asp:ImageButton ID="ImageButton1" CommandArgument='<%#Eval("roomid")%>' CommandName="up"
                            ImageUrl="images/edit.gif" runat="server" />
                    </td>
                    <td width="80">
                        <asp:ImageButton ID="imgbtndelete" CommandArgument='<%#Eval("roomid")%>' CommandName="de"
                            ImageUrl="images/delete.gif" runat="server" />
                    </td>
                </tr>
            </ItemTemplate>
                </table>
        </asp:Repeater>后台代码 :    protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string cmd = e.CommandName;
            int roomId = Convert.ToInt32(e.CommandArgument);
            if (cmd == "de")
            {
                RoomManager.DeleteRoom(roomId);
            }
            else if (cmd == "up")
            {
                Page.Server.Transfer("roomOperate.aspx?rid=" + roomId + "&op=u");
            }    }
      

  3.   

    repeater 中设置模板列
    通过遍历修改数据
    foreach(RepeaterItem item in Repeater1.Items){}
      

  4.   

    遍历repeater中的项,找到要修改的id,可以加个checkbox,获取checkbox中选中的id值protect void btn_click()
    {
       foreach(RepeaterItem item in Repeater1.Items)
       {
          Checkbox ch = item.FindControl("CheckBoxID") as CheckBox;
          if(ch.checked)
          {
              int id = convert.toint32(ch.value);
              //修改删除
          }
        }
    }