2
Reply

how to get command argument of link button in radiobtnlist?

Aniruddh Kewat

Aniruddh Kewat

Jun 17 2015 10:29 PM
876
i have got 4 linkbutton controls with command arguments....when the linkbutton is clicked it populates the datalist based on the command argument...
and i have a radio button list control that filters  the data  according to price that is populated in the datalist......
on page load,the datalist is populated with all the items....when i use rbtnlistcontrol on page load,it works as expected, but when i click any link button and then price radiobutton control,it doesn't filter the result/data.....
 
here's my html,
 
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div id="main" style="width: 70%; margin: 0 auto; background-color:Aqua">
<div id="header">
<ul>
<li>
<asp:LinkButton CssClass="clbtnmenu" ID="LinkButton1" runat="server" data-id="1"
CommandArgument="1" OnClick="lbtnmenu_click">Mobile</asp:LinkButton></li>
<li>
<asp:LinkButton CssClass="clbtnmenu" ID="LinkButton2" runat="server" data-id="2"
CommandArgument="2" OnClick="lbtnmenu_click">Shoes</asp:LinkButton></li>
<li>
<asp:LinkButton CssClass="clbtnmenu" ID="LinkButton3" runat="server" data-id="3"
CommandArgument="3" OnClick="lbtnmenu_click">Bags</asp:LinkButton></li>
<li>
<asp:LinkButton CssClass="clbtnmenu" ID="LinkButton4" runat="server" data-id="4"
CommandArgument="4" OnClick="lbtnmenu_click">Clothing</asp:LinkButton></li>
</ul>
</div>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
<div id="content" style="width: 100%">
<div id="leftcontent" style="width: 15%; float: left;">
<div id="divbrands">
<asp:Label CssClass="clblpricebrands" ID="lblbrands" runat="server" Text="BRANDS"></asp:Label>
<asp:RadioButtonList CssClass="crblpricebrands" ID="rblbrands" runat="server" AutoPostBack="True"
RepeatLayout="Table"
onselectedindexchanged="rblbrands_SelectedIndexChanged">
</asp:RadioButtonList>
</div>
<div id="divpricerange">
<asp:Label CssClass="clblpricebrands" ID="lblpricerange" runat="server" Text="Price Range"></asp:Label>
<asp:RadioButtonList CssClass="crblpricebrands" ID="rblpricerange" runat="server"
AutoPostBack="True" Font-Size="1em" Width="100%"
onselectedindexchanged="rblpricerange_SelectedIndexChanged">
<asp:ListItem Value="1">Rs.2000 and Below</asp:ListItem>
<asp:ListItem Value="2">Rs.2001-Rs.5000</asp:ListItem>
<asp:ListItem Value="3">Rs.5001-Rs.10000</asp:ListItem>
<asp:ListItem Value="4">Rs.10001-Rs.18000</asp:ListItem>
<asp:ListItem Value="5">Rs.18001-Rs.25000</asp:ListItem>
<asp:ListItem Value="6">Rs.25001-Rs.35000</asp:ListItem>
<asp:ListItem Value="7">Rs.35001 and Above</asp:ListItem>
</asp:RadioButtonList>
</div>
</div>
<div id="rightcontent" style="width: 85%; float: left;">
<div id="dvCustomers" style="width: 100%;overflow: auto; background-color: Black;">
<asp:DataList ID="dlCustomers" runat="server" RepeatLayout="Table" RepeatColumns="4"
RepeatDirection="Horizontal" CellPadding="0" CellSpacing="0" BackColor="Aqua"
Width="100%">
<ItemStyle Width="25%" />
<ItemTemplate>
<table cellpadding="0" cellspacing="0" border="0" style="width: 100%; height: 300px;
border: 2px solid Blue; background-color: Green; text-align: center">
<tr>
<td>
<b><u><span class="name">
<%# Eval("Name") %></span></u></b>
</td>
</tr>
<tr>
<td>
<b>Productid: </b><span class="productId" style="font-size: 20px; color: Yellow;
font-weight: 500;">
<%# Eval("Productid") %></span><br />
<b>Description </b><span class="description">
<%# Eval("Description") %></span><br />
<b>ImageUrl: </b><span class="imageUrl">
<%# Eval("ImageUrl")%></span><br />
<img class="image" alt='' src="Images/<%# Eval("ImageUrl")%>" width="160px" height="320px" /><br />
<b>Price: </b><span class="price">
<%# Eval("Price")%></span>
<img alt="" src="star-icon.png" />
<b>Quantity: </b><span class="quantity">
<%# Eval("Quantity")%></span><br />
<button onclick="return false;">
Add To Cart</button>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</div>
<img id="loader" alt="" src="WAITING.gif" style="display: none; height: 300px" />
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</form>
 
 & here's my code for selectec index changed
 
protected void rblpricerange_SelectedIndexChanged(object sender, EventArgs e)
{
   string brands = null;
   if (rblbrands.Items.Cast<ListItem>().Any(x => x.Selected))
      {
          brands = rblbrands.SelectedItem.Text;
      }
   int price = Convert.ToInt32(rblpricerange.SelectedValue); 
/*dlCustomers.DataSource = GetCustomersData(pageindex,categoryid,brands,price); */
    
 
  dlCustomers.DataSource = GetCustomersData(1, 0, brands, price);
  dlCustomers.DataBind();
  Label1.Text = "Radio button list value : " + rblpricerange.SelectedValue;
}
 
 
 
 
thanks in advance......
 

Answers (2)