ASPX templates
Version 4.x > ASPX templates > DropDownList to DataLIst View modes: 
User avatar
Member
Member
celsopaulo_bronze-hotmail - 4/23/2010 8:48:37 AM
   
DropDownList to DataLIst
Hi

I'm using ASPX Templates and I´ve a page with a DataList control and a DropDOwnList control, i´d like to know how can I pass a value from the DropDownList to the WhereCondition of the DropDownList. I've used the following aproch but did not work, please somebody help me.

<td class="ContainerWithCornersLeft">
<% string valueFromDropDown = "Year(PublishDate)= "+ ano.SelectedValue;
%>
</td>
<td align="left">
<cms:CMSDataList ID="CMSDataList1" runat="server" ClassNames="custom.balancomensais"
SelectedItemTransformationName="custom.balancomensais.Default" TransformationName="custom.balancomensais.preview"
RepeatColumns="1" EnablePaging="True"
WhereCondition="<%=valueFromDropDown%>">
</cms:CMSDataList>
</td>

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 4/28/2010 3:34:42 AM
   
RE:DropDownList to DataLIst
Hello,

I would recommend passing value to WhereCondition property of CMSDataList in code-behind, e.g. in SelectedIndexChanged method of dropdown list. In this case any time you change the value in dropdown list it will reload the data in CMSDataList so they match the new value.

Best Regards,

Martin Dobsicek




User avatar
Member
Member
celsopaulo_bronze-hotmail - 4/28/2010 8:45:10 PM
   
RE:DropDownList to DataLIst
Hi,
thanks for your reply, but I already made this, other properties, such as EnablePaging had functioned very well, but the property wherecondition not, can you tell me what is happening here is the code:

protected void button_1_Click(object sender, EventArgs e)
{
CMSDataListID.WhereCondition = "DataBasecolumn = " + " ' "+DropDownListID.SelectedValue+" ' ";
}

User avatar
Kentico Developer
Kentico Developer
kentico_martind - 4/29/2010 2:48:11 AM
   
RE:DropDownList to DataLIst
Hello,

It's necessary to reload data after you set properties in code-behind. Please add following sample code into end of button_1_Click method:

CMSDataListID.ReloadData(true);


Best Regards,

Martin Dobsicek


User avatar
Member
Member
celsopaulo_bronze-hotmail - 4/29/2010 6:55:06 AM
   
RE:DropDownList to DataLIst
Hello,

thanks a lot, your solution has resulted, I put the sample code you gave me into end of button_1_Click and now working well.
thanks