Button inside a repeater with dropdownlist

Posted by TheAlbear on Stack Overflow See other posts from Stack Overflow or by TheAlbear
Published on 2010-05-27T12:02:38Z Indexed on 2010/05/27 12:31 UTC
Read the original article Hit count: 183

Filed under:
|
|
|

I have a repeater with a literal, a dropdown list, and a button.

  <asp:Repeater ID="Repeater1" runat="server" OnItemDataBound="rep_ItemDataBound" onitemcommand="Repeater1_ItemCommand">
        <ItemTemplate>
          <div class="buypanel">
        <ul>
            <li>Choose finish <asp:DropDownList ID="ddlFinish" runat="server"></asp:DropDownList></li>
            <li>Qty <asp:Literal ID="ltQty" runat="server"></asp:Literal></li>
            <li><asp:Button ID="butBuy" runat="server" Text="Button" /></li>
        </ul>
        </div>
    </ItemTemplate>
    </asp:Repeater>

I am binding all the information in the code behind like

 protected void rep_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                Products product = (Products) e.Item.DataItem;


               //Dropdownlist to be bound. 

                //Set Buy Button
                var butBuy = (Button) e.Item.FindControl("butBuy");
                butBuy.CommandName = "Buy";
                butBuy.CommandArgument = product.Id.ToString();

            }
        }

and i have my itemcommand to pick up on the button click

  protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if(e.CommandName == "Buy")
            {

            }
        }

I am not sure how, with a given button click, to pickup the right information from the text box and dropdown list which is along side it?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about webforms