Prevent RadCombobox close with checkbox - c#

I have a RadComboBox with the checkboxes for Multiselction. I want to have a postback for the ItemChecked event.
The combobox also is generating a postback on closing of the dropdown which I do not want. How can I prevent this to happen.
<telerik:RadComboBox RenderMode="Lightweight" ID="RadComboBox1" runat="server" CheckBoxes="true" EnableCheckAllItemsCheckBox="true" CssClass="modaldropdown" ZIndex="99999999"
Width="600px" Label="Select book genres:" OnDataBound="RadComboBox1_DataBound" OnItemChecked="RadComboBox1_ItemChecked" AutoPostBack="true">
<ItemTemplate>
<ul>
<li>
<strong>Name: </strong>
<%# DataBinder.Eval(Container.DataItem, "Name")%>
</li>
<li>
<strong>Email: </strong>
<%# DataBinder.Eval(Container.DataItem, "Email")%>
</li>
<li>
<strong>Department: </strong>
<%# DataBinder.Eval(Container.DataItem, "DepartmentName")%>
</li>
<li>
<strong>Division: </strong>
<%# DataBinder.Eval(Container.DataItem, "DivisionName")%>
</li>
</ul>
</ItemTemplate>
c# CodeBehind
protected void RadComboBox1_ItemChecked(object sender, RadComboBoxItemEventArgs e)
{
string r = e.Item.Text;
string rw = e.Item.Value;
}

Related

How to remove menu class if submenu is empty

I have binding to <UL> using repeater control.
<ul id="menu-content" class="menu-content collapse out">
<asp:Repeater ID="rptMenu" runat="server" OnItemDataBound="rptMenu_OnItemBound">
<ItemTemplate>
<li data-toggle="collapse" data-target="#li<%# ((RepeaterItem)Container).ItemIndex + 1%>" class="collapsed active"><a id="A1">
<asp:HiddenField ID="HiddenField1" runat="server" Value='<%#Eval("Id") %>' />
<%#Eval("Name")%>
<span class="arrow"></span></a>
</li>
<ul class="sub-menu collapse" id="li<%# ((RepeaterItem)Container).ItemIndex + 1%>">
<asp:Repeater ID="rptChildMenu" runat="server">
<ItemTemplate>
<li>
<a id="A2" href='<%#Eval("Name") %>' runat="server"><%#Eval("Name")%></a>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</ItemTemplate>
</asp:Repeater>
</ul>
If there are no sub-menu item(s), arrow icon should be hidden or should not be rendered:
<span class="arrow"></span>

How to pass data to Link button onclick event

/*help me i am stuck here on how to pass <%# DataBinder.Eval(Container.DataItem, "Site_No") %> as parm to link button when clicked */
<ItemTemplate >
<!-- small box -->
<div class='<%# DataBinder.Eval(Container.DataItem, "Status") %>'>
<div class="inner">
<h3><asp:Label ID="lblSiteNo" runat="server"><%# DataBinder.Eval(Container.DataItem, "Site_No") %><sup style="font-size: 20px"></sup></asp:Label></h3>
<p><%# DataBinder.Eval(Container.DataItem, "Site_Size") %></p>
</div>
<asp:LinkButton ID="LinkButton1" CssClass="small-box-footer" OnClick="" runat="server">More info</asp:LinkButton>
</div>
</ItemTemplate>
</asp:DataList>
Instead of using OnClick event, use the CommandName and CommandArgument properties.
<asp:LinkButton ID="LinkButton1" CssClass="small-box-footer" CommandName="MoreInfo_Command" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "PARAM_NAME") %>' runat="server">More info</asp:LinkButton>
In your code behind:
void MoreInfo_Command(Object sender, CommandEventArgs e)
{
string parameter = e.CommandArgument;
}

how use If Statement in aspx page

I have on ListView
<asp:ListView ID="MyListView" runat="server">
<LayoutTemplate>
<ul class="menu">
<li><i></i>home</li>
<li runat="server" />
<li class="myClass">
<a title="SomeTitle" href="example.com/default.aspx">
</a>
</li>
</ul>
<ascx:Menu runat="server" Visible="true" />
</LayoutTemplate>
<ItemTemplate>
<li>
<asp:HyperLink runat="server" NavigateUrl='<%# Eval("URL") %>'
Text='<%# Eval("Title") %>'/></li>
</ItemTemplate>
<SelectedItemTemplate>
<li class="active">
<asp:HyperLink runat="server" NavigateUrl='<%# Eval("URL") %>'
Text='<%# Eval("Title") %>' /></li>
</SelectedItemTemplate>
</asp:ListView>
on .cs file I have one string
protected string CurrentName = MyMethod();//that return a string or null
in aspx page I want to show in <LayoutTemplate> different structure of tags in dependecy of my CurrentName
I try like this:
<% if(this.CurrentName ==null){ %>
<ul class="menu">
<li><i></i>home</li>
<li runat="server" />
<li class="myClass">
<a title="SomeTitle" href="example.com/default.aspx">
</a>
</li>
</ul>
<ascx:Menu runat="server" Visible="true" />
<% } else { %>
<ul class="menu">
<li><i></i>home</li>
<li class="myClass">
<ascx:Menu runat="server" Visible="true" />
</li>
</ul>
<% } %>
this method not work, how use IF statements in ASPX page right?
I would implement this with two panels which have exlusive conditions on Visible attribute, so that only one of them is rendered at a single load:
<asp:Panel runat="server" Visible='<%# this.CurrentName == null %>'>
<ul class="menu">
<li><i></i>home</li>
<li runat="server" />
<li class="myClass">
<a title="SomeTitle" href="example.com/default.aspx">
</a>
</li>
</ul>
<ascx:Menu runat="server" Visible="true" />
</asp:Panel>
<asp:Panel runat="server" Visible='<%# this.CurrentName != null %>'>
<ul class="menu">
<li><i></i>home</li>
<li class="myClass">
<ascx:Menu runat="server" Visible="true" />
</li>
</ul>
</asp:Panel>

How to bind Nested Repeaters?

I have a service page, which shows service details and has a sub-section like service features and charges. I created two repeaters for features and charges. Please refer to the following sql tables image for more information:
But I have no idea how to bind this hierarchical data to nested repeaters. Here is my code:
<!--Nested Repeater Section-->
<asp:Repeater ID="ServiceDetailsRepeater" runat="server"
onitemdatabound="ServiceDetailsRepeater_ItemDataBound">
<ItemTemplate>
<asp:HiddenField ID="service_id" runat="server" Value='<%#Eval("Id")%>'/>
<h3><a name='<%#Eval("Id")%>'></a><%#Eval("Service_name")%></h3>
<img src='<%# "images/"+ Eval("ImageName")%>' alt="picture" width="48" height="48" class="img" />
<p><%#Eval("Service_desc")%></p>
<div id="Div1" class="clr" runat="server"> </div>
<div id="Div2" class="box" runat="server">
<div id="Div3" class="box_t" runat="server">
<asp:Panel ID="Panel_ServiceFeature" runat="server" class="box_b">
<h2>Features</h2>
<ul style="font-family:Arial, Helvetica, sans-serif;font-size:11px;color:#5f5f5f">
<asp:Repeater ID="ServiceFeatureRepeater" runat="server">
<ItemTemplate>
<li><%#Eval("Feature_Text")%></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</asp:Panel>
</div>
</div>
<div id="Div5" class="clr" runat="server"> </div>
<div id="Div6" class="box" runat="server">
<div id="Div7" class="box_t" runat="server">
<asp:Panel ID="Panel_ServiceCharge" runat="server" class="box_b">
<h2>Charges</h2>
<table style="font-family:Arial, Helvetica, sans-serif;font-size:11px;color:#5f5f5f">
<tr><td></td>
<td>Rs.</td><td> </td><td align="left">Months</td></tr>
<asp:Repeater ID="ServiceChargeRepeater" runat="server">
<ItemTemplate>
<tr>
<td><img src="images/sub_nav.gif" width="18px" height="14px" alt=""/></td>
<td>Rs. <%#String.Format("{0:#,###}", Eval("Charges_Per_Month"))%></td>
<td> </td>
<td><%#Eval("No_Of_Month")%> Months</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</table>
</asp:Panel>
</div>
</div>
<div id="Div9" class="clr" runat="server"></div>
</ItemTemplate>
</asp:Repeater>
<!--End Section-->
Finally, my web site page this is my live web site service page view. This page is static but now I want to bind this service details with database.
One way to do it is to simply bind the DataSource property of the inner Repeater to a suitable collection. E.g. something like:
<asp:Repeater ID="ServiceDetailsRepeater" runat="server"
DataSourceID="SqlDataSource1">
<asp:Repeater ID="ServiceFeatureRepeater" runat="server"
DataSource="<%# DatabaseHelper.GetFeatures(Eval("Id")) %>">
...
</asp:Repeater>
<asp:Repeater ID="ChargesRepeater" runat="server"
DataSource="<%# DatabaseHelper.GetCharges(Eval("Id")) %>">
...
</asp:Repeater>
</asp:Repeater>
i have also check if no features or charges are found to particular service then panel have to off. so i directly doing from code behind
UPDATE
If you're more comfortable doing it from code-behind, go ahead, but you could also do it declaratively by databinding the Repeater's Visible property, e.g.:
...
<asp:Repeater ID="ServiceFeatureRepeater" runat="server"
DataSource="<%# DatabaseHelper.GetFeatures(Eval("Id")) %>"
Visible="<%# DatabaseHelper.HasFeatures(Eval("Id")) %>"
>
...
</asp:Repeater>
....
if (!Page.IsPostBack)
{
ServiceListRepeater.DataSource = DatabaseHelper.GetSummaryOfActiveServices();
ServiceListRepeater.DataBind();
ServiceDetailsRepeater.DataSource = DatabaseHelper.GetSummaryOfActiveServices();
ServiceDetailsRepeater.DataBind();
}
protected void ServiceDetailsRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
RepeaterItem item = e.Item;
if ((item.ItemType == ListItemType.Item) ||(item.ItemType == ListItemType.AlternatingItem))
{
HiddenField service_id = (HiddenField)item.FindControl("service_id");
Repeater service_features = (Repeater)item.FindControl("ServiceFeatureRepeater");
service_features.DataSource = DatabaseHelper.GetFeatureSummary(int.Parse(service_id.Value.ToString()));
service_features.DataBind();
if (service_features.Items.Count == 0)
{
Panel Panel_ServiceFeature = (Panel)item.FindControl("Panel_ServiceFeature");
Panel_ServiceFeature.Visible = false;
}
Repeater service_charges =(Repeater)item.FindControl("ServiceChargeRepeater");
service_charges.DataSource = DatabaseHelper.GetChargeSummary(int.Parse(service_id.Value.ToString()));
service_charges.DataBind();
if (service_charges.Items.Count == 0)
{
Panel Panel_ServiceCharge = (Panel)item.FindControl("Panel_ServiceCharge");
Panel_ServiceCharge.Visible = false;
}
}
}

How to increase row of a repeater as text increases?

How to increase row of a repeater as text increases? I am using a repeater to display image , and image description .if image description contains more character , the text is overlapping with the other rows . how can i solve this problem?
<HeaderTemplate>
<div class="HeaderStyle">
<div class="HeaderStyle5">Edit</div>
<div class="HeaderStyle5">Delete</div>
<div class="HeaderStyle1">Image</div>
<div class="HeaderStyle2">ImageDescription</div>
</div>
<ul id="defaultList">
</HeaderTemplate>
<ItemTemplate>
<li id='item_<%# Container.ItemIndex + 1 %>' originalId='<%# DataBinder.Eval(Container.DataItem, "ImageId") %>' class="itemStyle">
<div class="itemStyle">
<div class="itemStyle4"> <asp:HyperLink ID="LinkButton2" runat="server" Text="Edit" NavigateUrl='<%#Request.Url.AbsoluteUri+"&ImageId="+ DataBinder.Eval(Container.DataItem, "ImageId") %>'></asp:HyperLink> </div>
<div class="itemStyle5">
<asp:LinkButton ID="lnkDelete" runat="server"
CommandName='<%# DataBinder.Eval(Container.DataItem, "ImageId") %>' CommandArgument='<%# DataBinder.Eval(Container.DataItem, "SortId") %>' OnClientClick="return confirm('Are you sure , you want to delete..?');" OnCommand="Calling_Delete" >Delete</asp:LinkButton> </div>
<div class="itemStyle1"><asp:Image ID="Image1" runat="server" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "ImageUrl") %> ' Height="50px" Width="50px" /> </div>
<div><%# DataBinder.Eval(Container.DataItem, "ImageDesc") %> </div>
</div>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
Use
myRepeater.Attributes["Style"] = "OVERFLOW-Y:auto;";

Categories

Resources