Tag Archives: Repeater

Repeater

[RESOLVED]label style

hi,

I have a label button inside a repeater.it already have a class for alignment.

I want to add the color for the label text dynamically in code behind, but is not applying.

 Dim mrklink As Label = TryCast(newitems.FindControl("lbl_ID"), Label)
                mrklink = New Label
                If val 1< val 2 Then
                    mrklink.ForeColor = Color.Red
end if


Why re you re-instantiating the label? Use the following code in the repeater ItemDateBound event

If e.Item.ItemType = ListItemType.Item or e.Item.ItemType = ListItemType.AlternatingItem Then
Dim mrklink As Label = TryCast(newitems.FindControl("lbl_ID"), Label)
    If mrklink isNot Nothing Then                
         If val 1< val 2 Then
            mrklink.ForeColor = Color.Red
         End if
    End If
End If

Need details to the way

Hi,
I want to have repeater control on the right the menu (each TAB sub-menu items) below

    <style type="text/css">
        #container{
            height:200px;
            background-color:black;
        }

...
                    </li>
                    <li><a href="#">
                        <div class="imagesList-item-frame shadow">
                            <img src=<%=lb_pict2.Text %> onclick="pict_click2();" />
                            <div class="legend">
                                <div style="height:18px; width:92px; font-size:small; border:none; background-color:#1BA8E0">
                                    <label id="Label23" runat="server"><b>Test</b></label>
                                </div>
                            </div>
                        </div>
                    </li>
                </ul>
            </li>
        </ul>
    </div>
    ...

and then center the div that is having both the menu and the repeater control inside, on the page. is there any demonstration to do this?

Hi HuaMin,

Thanks for your post.

This article show us how to create multi-level navigational menu with the ASP.NET Repeater control and CSS styles, you could refer to it.

Hope it will be helpful to you.

Best Regards,

Fei Han

how to adjust the css codes below

    <style type="text/css">
        #horizontalmenu {
          /*text-align: center;
          margin-left:120px;*/
          width:90%;
          margin:auto;
        }
        #horizontalmenu > ul {
          padding: 1px;
          margin: 1px;
          list-style: none outside none;
          display: inline-block;
        }
...
	    <SeparatorTemplate>
	    </SeparatorTemplate>
	    <FooterTemplate>
		    <div class="headerFooter"></div>
	    </FooterTemplate>
    </asp:Repeater>
    <br />

to ensure the repeater above is aligned on the right of the TABs, of which each TAB is having a few sub-menu items? I expect that the TABs with sub-items are the green part below, while the reapeater is the blue part.

wmec

repeater above is aligned on the right of the TABs, of which each TAB is having a few sub-menu items? I expect that the TABs with sub-items are the green part below, while the reapeater is the blue part.

  1. You should not post all your code here, only that small piece which is directly related to the issue.
  2. What the exact issue? Please show the screenshot of the current output and a picture of expected result.

Now the repeater does not appear on the right side of the several TABs (while each each TAB is having sub-items). This is what I expect to adjust.

Hi wmec,

wmec

to ensure the repeater above is aligned on the right of the TABs

According to your description and picture, I recommend to divide the page into two parts, we could use the first one to display menu and use the second one to display repeater. You could refer to the below sample to divide your page.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style>
        #horizontalmenu {
            /*text-align: center;
          margin-left:120px;*/
            width: 90%;
            margin: auto;
            display:block;
            float:left;
        }

        #repcontainer{
            width:9%;
            display:block;
            float:left;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <div id="horizontalmenu">
            </div>
            <div id="repcontainer">
            </div>
        </div>
    </form>
</body>
</html>

Best Regards,

Fei Han

Usually alignment could be done using one of 2 techniques

  1. have a table <table><tr><td> first container here </td><td> second container here </td></tr></table>. 
  2. have containers such as <div> with float:left/right <div style="width:400px;float:left"> first container here </div><div style="width:400px;float:left"> second container here </div>

Thanks a lot to all.
Fei Han,
I expect to show the repeater on the right of the TABs (of which each is having sub-items). but using these

    <style type="text/css">
        #horizontalmenu {
          width:60%;
          display:block;
          float:left;
        }
        #repcontainer {
            width:15%;
            display:block;
            float:left;
        }
        #horizontalmenu > ul {
          padding: 1px;
          margin: 1px;
          list-style: none outside none;
          display: inline-block;
        }
        #horizontalmenu > ul > li {
            text-align: left;
            display: block;
            border: 4px solid #CC55FF;
            border-style: inset;
        }
        #horizontalmenu li ul {
            display: none;
            position: absolute;
        }
        #horizontalmenu li:hover ul {
            display: block;
            background: #7C7A82;
            height: auto;
        }
...

        <asp:Repeater ID="Repeater" runat="server">
	        <HeaderTemplate>
	        </HeaderTemplate>
            <ItemTemplate>
		        <asp:LinkButton ID="Link1" runat="server" Text='<%# Eval("row1") %>' BackColor="#57789E" Width="820px" 
                    ForeColor="White" Font-Bold="true" Font-Names="Arial" style="line-height:33px" 
                    ToolTip="Double-click the line to locate to the record" OnClick="bt_Click" />
            </ItemTemplate>
	        <SeparatorTemplate>
	        </SeparatorTemplate>
	        <FooterTemplate>
		        <div class="headerFooter"></div>
	        </FooterTemplate>
        </asp:Repeater>
    </div>

the repeater is still shown underneath the TABs. why?

Smirnov,

Can you advise why I encounter the problem, using the above codes?

Any help to this?

[RESOLVED]Keeping an option list within a Repeater Open inspite intital CSS.

I have a Repeater with CSS designed to Open/Close upon clicking on the ‘+’/’-’ (see below):

--- CSS ---
sliding-box .box-content{
	width:646px;
	margin:7px 0 0;
	padding:16px 20px 18px;
	background:#fff;
}
.sliding-box .box-content:after{
	content:"";
	display:block;
	clear:both;
}

--- HTML ---
<div class="box-content" style="display: none;">
    <ul class="list-options">
        <asp:Repeater ID="ProductOptions" runat="server" OnItemDataBound="ProductOptions_ItemDataBound">
            <ItemTemplate>
                <li>
                    <asp:CheckBox runat="server" ID="OptionCheckbox" CssClass="checkbox" OnCheckedChanged="OptionCheckbox_CheckedChanged" AutoPostBack="true" />
                </li>
            </ItemTemplate>
        </asp:Repeater>
    </ul>
</div>

--- Page Renders as per below --------
// 1. Upon initial Page Load
+ Options

// 2. When clicking on the '+', checkboxes are displayed
- Options
   Checkbox 1
   Checkbox 2
   Checkbox 3

When Selecting a Checkbox, a Postback occurs which collapses the Options List.

Can someone show me how to keep this Option List object Open after selecting the Checkbox?

Hi baruchb,

Thanks for your post.

As for your problem, I’d like to know how do you open the Option List when you click the ‘+’. Could you show us more relevant code? It will help us to reproduce your problem.

Best Regards,

Fei Han

Sure! Below is the full HTML for this section followed by the CSS for the SlidingBox. I am not an expert on CSS so I am not sure if/how to ‘doctor’ the CSS to make this happen. Bottom line is that: I need the sliding box to be closed for ALL page loads except
when PostBack from a Checkbox within the repeater (which I am able to detect at Page_Load by interrogating the Request.Params["_EVENTTARGET"].

HTML
----
<asp:Panel ID="ProductOptionsPanel" runat="server">
    <!-- product options -->
    <div class="sliding-box">
        <div class="sliding-box-holder">
            <div class="title">
                <a href="#" class="open-close">
                    <asp:Literal ID="OptionsTitle" runat="server" />
                    - Options</a>
            </div>
            <div class="box-content">
                <ul class="list-options">
                    <asp:Repeater ID="ProductOptions" runat="server" OnItemDataBound="ProductOptions_ItemDataBound">
                        <ItemTemplate>
                            <li>
                                <asp:CheckBox runat="server" ID="OptionCheckbox" CssClass="checkbox" OnCheckedChanged="OptionCheckbox_CheckedChanged" AutoPostBack="true" />
                                <div class="holder">
                                    <asp:Literal ID="Description" runat="server" />
                                    <asp:HiddenField ID="Code" runat="server" />
                                    <asp:HiddenField ID="SalesItemNumber" runat="server" />
                                </div>
                            </li>
                        </ItemTemplate>
                    </asp:Repeater>
                </ul>
            </div>
        </div>
    </div>

<!--child options -->
<asp:panel id="ChildOptionsPanel" CSSClass="sliding-box" runat="Server">
.
.
.
CSS
---
/* sliding-box */
.sliding-box{
	width:100%;
	position:relative;
	z-index:5;
	padding:0 0 10px;
	color:#242424;
}
.sliding-box-holder{
	height:1%;
	padding:7px;
	background:#e9eaec;
}
.sliding-box-holder:after{
	content:"";
	display:block;
	clear:both;
}
.sliding-box .title{
	width:100%;
	overflow:hidden;
}
.sliding-box .open-close{
	height:1%;
	overflow:hidden;
	display:block;
	padding:0 36px;
	font-size:16px;
	line-height:38px;
	color:#242424;
	background: url(images/bg-sliding-box-close.gif) no-repeat 5px 50%;
}
.active .open-close{background: url(images/bg-sliding-box-open.gif) no-repeat 5px 50%;}
.sliding-box .open-close:hover{
	color:#c6178d;
	text-decoration:none;
}
.sliding-box .open-close img{
	float:left;
	margin:0 10px 0 0;
}
.sliding-box .box-content{
	width:646px;
	margin:7px 0 0;
	padding:16px 20px 18px;
	background:#fff;
}
.sliding-box .box-content:after{
	content:"";
	display:block;
	clear:both;
}
.sliding-box .item-table .col-1{width:46%;}
.sliding-box .item-table .col-2{width:26%;}
.sliding-box .item-table .col-3{width:20%;}
.sliding-box .item-table .col-4{padding-right:10px;}
.sliding-box p{margin:0 0 21px;}
/* item-table2 */
.item-table2 .col-1,
.sliding-box .item-table2 .col-1{width:50%;}
.item-table2 .col-2,
.sliding-box .item-table2 .col-2{width:22%;}
.item-table2 .col-3,
.sliding-box .item-table2 .col-3{width:34%;}
.headline{
	height:1%;
	overflow:hidden;
}

You need to store the id of the open sections in a hidden field element and on postback ensure those fields are initially visible.  The following link is for remembering the selected tab between postbacks but the concept is the same, just adapt the code
as needed.

http://forums.asp.net/t/1964624.aspx?Maintaining+tab+position+on+post+back

My problem is not remembering WHAT to keep open but rather HOW. If you are versed in CSS or able to provide a solution for how to keep the SlideBox open given conditions specified in my previous thread, it will be greatly appreciated.

I posted code as per your request. Any idea yet?

Hi baruchb1,

baruchb1

My problem is not remembering WHAT to keep open but rather HOW.

Here is a Collapsible Repeater Demo, you could refer to it.

Besides, you could also refer to this article.

Hope it will be helpful to you.

Best Regards,

Fei Han

Horizontal menu having repeater control within each menu

Hi,

Is there one example to have one horizontal menu? And further within each menu, there is one repeater control inside. Any example to this?

Hi,

I do not know what do you mean with "one repeater". If you mean on menu there is a sub menu, this is may help. You need bootstrap.css and bootstrap.amelia.css. Both css can be installed using nuget package.

Here the example:

<nav class="navbar navbar-fixed-top navbar-inverse">
    <div class="navbar-header">
        <a href="/" class="navbar-brand"><span class="brand-title">Sales & Marketing</span></a>
        <a class="btn navbar-btn navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </a>
    </div>
    <div class="navbar-collapse collapse">
        <div class="pull-right navbar-logo">
            <ul class="nav navbar-nav pull-right">

                <li><a href="/documents/person-entity-manager.html" target="_blank">Presentation</a></li>

                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Detail View Design<span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu">
                        <li class="divider"></li>
                        <li>
                            <a href="/app/temp/product-view.html" target="_blank">
                                <!--<a href="http://192.168.151.3:1002/app/temp/product-view.html" target="_blank">-->
                                Product Details Info
                            </a>
                        </li>
                        <li class="divider"></li>
                    </ul>
                </li>

                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Administration<span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu">
                        <li>
                            <a href="http://192.168.151.3:1003" target="_blank">
                                Person Information Manager
                            </a>
                        </li>
                        <li>
                            <a href="http://192.168.151.3:1001" target="_blank">
                                Property Table
                            </a>
                        </li>
                        <li class="divider"></li>
                        <li class="dropdown dropdown-big">
                            <a href="http://192.168.151.3:1004" target="_blank">
                                Demo: No character is lost
                            </a>
                        </li>
                        <li class="divider">Real Time</li>
                        <li>
                            <a href="http://192.168.151.3:1005" target="_blank">
                                Demo: Line of Business Application
                            </a>
                        </li>
                        <li>
                            <a href="http://192.168.151.3:1006" target="_blank">
                                Demo: Real Time and Concurrent processing
                            </a>
                        </li>
                        <li>
                            <a href="http://192.168.151.3:1007" target="_blank">
                                Demo: Real Time Chat
                            </a>
                        </li>
                    </ul>
                </li>

                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">Sponsor<span class="caret"></span></a>
                    <ul class="dropdown-menu" role="menu">
                        <li>
                            <a href="http://usni.xx.id/" target="_blank">
                                Universitas Satya Negara Indonesia
                            </a>
                        </li>
                        <li>
                            <a href="http://www.polmed.xxx/" target="_blank">
                                Politeknik Negeri Medan
                            </a>
                        </li>
                        <li class="divider"></li>
                        <li class="dropdown dropdown-big">
                            <a href="http://www.facebook/someone" target="_blank">
                                Jendela Alam Raya
                            </a>
                        </li>
                        <li>
                            <a href="#" target="_blank">
                                Tolhas Tuna Tumure
                            </a>
                        </li>
                    </ul>
                </li>
                <li>
                    <a href="#" target="_blank">
                        <!--<span style="font-size:1.2em;">
                            Alzafandy Hikmad Inc, Ltd
                        </span>-->
                        Peter Thumb Property
                    </a>
                </li>
            </ul>
        </div>
    </div>
</nav>

Have fun.

Thanks. One repeater control means there is one repeater list within one menu. Where are bootstrap.css and bootstrap.amelia.css?

Hi,

Use Nuget Package, and type "Bootstrap" on search item, you can find Bootstrap, NOT "Twitter Bootstrap" this will install bootstrap.css and bootstrap.js. Also you can find bootstrap theme name "amelia"

Have fun

Thanks. Where to type "Bootstrap"?

Hi wmec,

Please run the following command in the Package Manager Console:

Install-Package bootstrap

Best Regards,

Kevin Shen.

Thanks.
I expect to see one example like

which is having TABs on top of the area and to each TAB, there is one repeater control shown as yellow rectangle under each TAB.

Any help to this?

Hi you can try this link

http://jqueryui.com/tabs/

hope this will help you.

Hi,

But I do not see one "Repeater control" within one TAB, to your example.

Unable to fire a click event using link button in repeater

Hi, 

I am using the Modal popup controler for showing the notification of new message by using Panel control . In that panel control i am using a repeater .

In repeater i have lable and link button . After i show the notification message using linkbutton the unread message will become read . But in that i am unable to fire the click event in

the linkbutton.

my code is : 

front end code:-

<asp:Panel ID="Panel3" runat="server" BackColor="white" style="display:none" BorderWidth="1" Width="500px" Height="200px" BorderColor="#108EBF">
<center>
<div class=" col-sm-5 ">

<asp:Repeater ID="rptnewmsg" runat="server" OnItemCommand="lnkmsgstatus_Command" >

<ItemTemplate>
<div style=" width:300px; height:150px; border:solid 0px red;">

<a style=" color:Black;"> File received from </a> <asp:Label ID="lblclientnamessTF" runat="server" Text=’<%#Eval("Clientname") %>’></asp:Label> <a style=" color:Black;"> for </a> <asp:Label ID="Label2" runat="server" Text=’<%#Eval("Boardtype") %>’></asp:Label>
<br />

<asp:LinkButton ID="lnkmsgstatus" runat="server" CommandArgument=’<%Eval("Id") %>’ CommandName="Unread" OnCommand="lnkmsgstatus_Command" Text="Unread" ></asp:LinkButton><br /><br />

</div>

</ItemTemplate>

</asp:Repeater>

<button id="btncancelss" type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<div class="modal-body" style=" margin-top:50px;">

<%–
<div class="well">

<div class="form-group">

<h4 class=" col-sm-offset-5 " style=" color:Black; " >Post Comments</h4>

<label for="name">Comments</label><br /> <asp:TextBox ID="TextBox1" runat="server" CssClass=" form-control"></asp:TextBox><br /><br />

</div>

</div>–%>
</div>

</div>

</center>
</asp:Panel>

<asp:ModalPopupExtender ID="ModalPopupExtender3" BehaviorID="ModalPopupExtender3" runat="server" Enabled="true" PopupControlID="Panel3" TargetControlID="Panel3" CancelControlID="btncancelss" OnCancelScript="hidepopupss()" BackgroundCssClass="modalback">
</asp:ModalPopupExtender>

c# code :-

protected void lnkmsgstatus_Click(object sender, EventArgs e)
{
string lnkbtnmsg = (sender as LinkButton).CommandArgument;
con.Open();

SqlCommand cmdupdatemsg = new SqlCommand("update Newmessage set Readstatus =’" + 1 + "’ where Id = ‘" + lnkbtnmsg + "’", con);
cmdupdatemsg.ExecuteNonQuery();

con.Close();

}

protected void Timer1_Tick(object sender, EventArgs e)
{

Newmsgbind();
ModalPopupExtender3.Show();

}

public void Newmsgbind()
{
SqlDataAdapter da_newmsg = new SqlDataAdapter("select Id,Clientname,Boardtype ,Date from Newmessage where Readstatus =’" + 0 + "’", con);
DataSet ds_newmsg = new DataSet();
da_newmsg.Fill(ds_newmsg);

rptnewmsg.DataSource = ds_newmsg;
rptnewmsg.DataBind();
}

Hi a.arunan,

Thanks for your post.

Firstly, you should implement Repeater.ItemCommand Event, this Event occurs when a button is clicked in the Repeater control.

Secondly, you should modify your code as below.

protected void lnkmsgstatus_Command(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName=="Unread")
            {
                //do some operations when click linkbutton

                string str = e.CommandArgument.ToString();
                con.Open();

                SqlCommand cmdupdatemsg = new SqlCommand("update Newmessage set Readstatus ='" + 1 + "' where Id = '" + lnkbtnmsg + "'", con);
                cmdupdatemsg.ExecuteNonQuery();

                con.Close();

            }
        }  

For more information about Repeater.ItemCommand Event, you could refer to the following link.

If you have any question about my reply, please let me know freely.

Best Regards,

Fei Han

Dear Fei Han,

Its not working

For some reason when you set a button as the TargetControlID of the modal popup ,it disables the Click event.

I suggest that you can set a hidden field first, then set the id  as the targetcontrolid for modal popup.

then  in the click event ,you can show the modal popup.

[RESOLVED]chcekbox with scroll option

Iam using vs2008 .I am trying to use checkbox list with scroll option  .please help me

Whats ur issue then?
Elaborate what do u mean by scrolling, and also explain the check box list u r using
and ur requirement

Thanks for reply.

Requirement
Display set of items and check box next to each of the selection and a check box with an open text field next to it.

how to achieve the open text field in checkboxlist

hi,

I think you can use test – checkbox – textbox sequence in side a repeater.

Place ur check box in a div, and make it scrollable using overflow attributes

[RESOLVED]Formview Not Visible

Hello. I have a little problem. I cant see the controls on this page either in Design mode or when I run it. The code is below. Thank you.

<asp:Repeater ID="Repeater1" runat="server">

                    <ItemTemplate>
                    
                    <asp:FormView ID="FormView1" runat="server">
                    
                    <ItemTemplate>
                    
                    <!-- Products -->
		     <ul class="products">
			<li class="product first">
				<a href="category-products.html">
				<img src="images/placeholder/small-product-220x164.jpg" alt="" title="" />
				<h3>Condos For Sale</h3>
				</a>
			</li>
										
			li class="product">
			           <a href="category-products.html">
				<img src="images/placeholder/small-product-220x164.jpg" alt="" title="" />
				<h3>Appartments For Rent</h3>
				</a>
			</li>

                               <li class="product last">
			       <a href="category-products.html">
			       <img src="images/placeholder/small-product-220x164.jpg" alt="" title="" />
				<h3>Condos For Rent</h3>
				</a>
			</li>

                    </ul>
                    
                    </ItemTemplate>
                    
                    </asp:FormView>

                    </ItemTemplate>
                    
                    </asp:Repeater>

I think the ItemTemplate tag is malformed.  You have an additional ItemTemplate tag ‘inside’ that first one.

I think there should only be one ItemTemplate, and you have two there. Plust, the ‘open’ of the FormView is in one, and the rest of the Form is in the other.  Put all the FormView stuff into either one, and try that.

You only able to see the FormView if you bind to DataSource with any records exist. If no record, the FormView will invisible except in insert mode.

Repeater control repeats the data’s if the data exist on debug. You can’t see in design mode because repeater contains them, if you compile you can manage. And also if you want to manage the control’s at repeater. Try This ;

protected void Repeater1_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
        YourItem yourItemName = new YourItem();
        yourItemName= (yourItem)e.Item.FindControl("repeaterControlWhichYouWantToManage");

        string strName = repeaterControlWhichYouWantToManage.Text.ToString();
    }
    }

Thanks

[RESOLVED]repeater in repeater

hi

i have a table in database,and each record of the table hase a type.

i want to display the fields of table,and group them by type field.

i have 2repeater.1 for type field,and 1 for all of another fields.

i want to have nested repeater,1 row for type,and the field of that type below

how can i do it?

 

TABLE1

YEAR     
SEMESTER

2001      1st

2001      2ND

2002      1st

2003      1st

2003      2nd

2. the semester should be grouped/show under the year like the sample below:

2001

     1st

     2nd

2002

     1st

2003

             1st

            2nd

i want this,please tell methe html codes and codebehind.

i want to do with c#

try this

<ul id="nav">
<asp:Repeater ID="dltMenuBar" runat="server"
onitemdatabound="dltMenuBar_ItemDataBound" >
<ItemTemplate>
<li><%#Eval("year") %>
<ul style="padding-top:8px;">
<asp:Repeater ID="dltMenuItems" runat="server">
<ItemTemplate>
<li><%#Eval("semister") %></li>
</ItemTemplate>
</asp:Repeater>
</ul>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>

protected void dltMenuBar_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
DataRowView drv = e.Item.DataItem as DataRowView;
Repeater innerDataList = e.Item.FindControl("dltMenuItems") as Repeater;
innerDataList.DataSource = drv.CreateChildView("yearsList");
innerDataList.DataBind();
}
}
public void getData()
{
SqlConnection myConnection = new SqlConnection("uid=sa;pwd=123;database=northwind");
SqlCommand myCommand = new SqlCommand("SELECT year FROM Table_1 where year IN ( SELECT year from Table_1 ) SELECT semister,year FROM Table_1 ", myConnection);

SqlDataAdapter ad = new SqlDataAdapter(myCommand);
DataSet ds = new DataSet();
ad.Fill(ds);
// Attach the relationship to the dataSet
ds.Relations.Add(new DataRelation("yearsList", ds.Tables[0].Columns["year"],
ds.Tables[1].Columns["year"]));
dltMenuBar.DataSource = ds.Tables[0];
dltMenuBar.DataBind();
}

[RESOLVED]Microsoft Jscript runtime error:object expected

 I am getting Microsoft Jscript runtime error:object expected in the following code. I try to identify the issue but unable to find. Please help me in finding the error.

<style type="text/css">
.AccordionTitle, .AccordionContent, .AccordionContainer
{
position: relative;
width: 240px;
}

.AccordionTitle
{
height: 20px;
overflow: hidden;
cursor: pointer;
font-family: Arial;
font-size: 12px;
font-weight: bold;
vertical-align: top;
text-align: left;
background-repeat: repeat-x;
display: table-cell;
background-image: url(‘title_repeater.jpg’);
-moz-user-select: none;
}

.AccordionContent
{
height: 0px;
overflow: auto;
display: none;
text-align:left;
background-color:White;
}

.AccordionContainer
{
border-top: solid 0px #C1C1C1;
border-bottom: solid 0px #C1C1C1;
border-left: solid 0px #C1C1C1;
border-right: solid 0px #C1C1C1;
}
</style>
<script type="text/javascript" language="javascript">
var ContentHeight = 200;
var TimeToSlide = 250.0;

var openAccordion = ”;

function runAccordion(index) {
var nID = "Accordion" + index + "Content";
if (openAccordion == nID)
nID = ”;

setTimeout("animate(" + new Date().getTime() + "," + TimeToSlide + ",’"
+ openAccordion + "’,’" + nID + "’)", 33);

openAccordion = nID;
}
function animate(lastTick, timeLeft, closingId, openingId) {
var curTick = new Date().getTime();
var elapsedTicks = curTick – lastTick;

var opening = (openingId == ”) ? null : document.getElementById(openingId);
var closing = (closingId == ”) ? null : document.getElementById(closingId);

if (timeLeft <= elapsedTicks) {
if (opening != null)
opening.style.height = ContentHeight + ‘px’;

if (closing != null) {
closing.style.display = ‘none’;
closing.style.height = ’0px’;
}
return;
}

timeLeft -= elapsedTicks;
var newClosedHeight = Math.round((timeLeft / TimeToSlide) * ContentHeight);

if (opening != null) {
if (opening.style.display != ‘block’)
opening.style.display = ‘block’;
opening.style.height = (ContentHeight – newClosedHeight) + ‘px’;
}

if (closing != null)
closing.style.height = newClosedHeight + ‘px’;

setTimeout("animate(" + curTick + "," + timeLeft + ",’"
+ closingId + "’,’" + openingId + "’)", 33);
}
</script>
<script language="javascript" type="text/javascript">

function ShowNewsDetails(layer_ref) {
//debugger;
var DivID = document.getElementById(layer_ref);

if (DivID.style.display == ‘block’) {
DivID.style.display = ‘none’;
return false;
}
var NewsCount = document.getElementById("");
var DivID_ID = DivID.id;
//for (i = 0; i < 100; i++) {
for (i = 1; i < 7; i++) {
var tempDivId = "DivNewsDetails" + i;
if (DivID_ID != tempDivId) {
document.getElementById(tempDivId).style.display = ‘none’;
}
else if (DivID_ID == tempDivId) {
DivID.style.display = ‘block’;
}
}
}
//function showhideContent(layer_ref, layer2_ref) {
function showhideContent(layer_ref) {
debugger;
var DivID = document.getElementById(layer_ref);
//var DivNewsDID = document.getElementById(layer2_ref);
//alert(DivID);
//
if (DivID.style.display == ‘block’) {
DivID.style.display = ‘none’;
return false;
}
var NewsCount = document.getElementById("ctl00_cphDefault_NewsCount").value;
var DivID_ID = DivID.id;
//for (i = 0; i < 100; i++) {
for (i = 1; i < NewsCount; i++) {
var tempDivId = "NL" + i;
var tempNDId = "ND" + i;
if (DivID_ID != tempDivId) {
document.getElementById(tempDivId).className = "LtPanelGradiantWhite CursorAll";
document.getElementById(tempDivId).style.color = "Gray";
document.getElementById(tempNDId).style.backgound-image = "images/newsBack.png";

}
else if (DivID_ID == tempDivId) {
document.getElementById(tempDivId).className = "LtPanelGradiant clsWhite CursorAll";

document.getElementById(tempDivId).style.color = "white";
document.getElementById(tempNDId).style.backgound-image = "images/newsBackActive.png";
}
}
}
</script>

html code:

<table>
<tr>
<td style="width:30%">
<div id="AccordionContainer" class="AccordionContainer">
<table>
<tr>
<td id="ctl00_cphLeftPanel_tdNewsList">
<div onclick=’runAccordion(1);’>
<div class=’AccordionTitle’ onselectstart=’return false;’>March 2012</div>
</div>
<div id=’Accordion1Content’ class=’AccordionContent’>
<a id="NL1" onclick="javascript:showhideContent(‘NL1′);">ttttt</a><br />
<div id=’NL2′ onclick=javascript:showhideContent(‘NL2′) >test3</div></br>
<div id=’NL3′ onclick=javascript:showhideContent(‘NL3′) >hhhh</div>
</div>
<div onclick=’runAccordion(4);’>
<div class=’AccordionTitle’ onselectstart=’return false;’>February 2012</div>
</div>
<div id=’Accordion4Content’ class=’AccordionContent’>
<div id=’NL4′ onclick=’javascript:showhideContent(‘NL4′)’ >test</div></br>
<div id=’NL5′ onclick=javascript:showhideContent(‘NL5′) >University of Colorado, Colorado Springs selects EMS</div></br>
<div id=’NL6′ onclick=javascript:showhideContent(‘NL6′) >Oklahoma State University Center for Health selects EMS</div></br>
<div id=’NL7′ onclick=javascript:showhideContent(‘NL7′) >San Jose State University selects EMS</div></br>
<div id=’NL8′ onclick=javascript:showhideContent(‘NL8′) >Hennepin County Medical Center selects EMS</div>
</div>
<div onclick=’runAccordion(9);’>
<div class=’AccordionTitle’ onselectstart=’return false;’>January 2012</div></div><div id=’Accordion9Content’ class=’AccordionContent’><div id=’NL9′ onclick=’javascript:showhideContent(‘NL9′)’ >Madonna University selects EMS</div></br><div id=’NL10′ onclick=javascript:showhideContent(‘NL10′)
>Regina Qu’Appelle Health Region selects EMS</div></div><div onclick=’runAccordion(11);’><div class=’AccordionTitle’ onselectstart=’return false;’>December 2011</div></div><div id=’Accordion11Content’ class=’AccordionContent’><div id=’NL11′ onclick=’javascript:showhideContent(‘NL11′)’
>Stillman College Nursing Department selects EMS</div></div><div onclick=’runAccordion(12);’><div class=’AccordionTitle’ onselectstart=’return false;’>November 2011</div></div><div id=’Accordion12Content’ class=’AccordionContent’><div id=’NL12′ onclick=’javascript:showhideContent(‘NL12′)’
>EMS Ranked a Top Technology Employer</div></br><div id=’NL13′ onclick=javascript:showhideContent(‘NL13′) >McClennan Community College selects EMS</div></div></td>

</tr>
</table>
</div>
</td>
<td style="width:5%"></td>
<td style="width:65%">
<div Id=’NewsDisplayByMonth1′><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND1′ style=’background-image: url(images/newsBackActive.png); background-repeat: no-repeat;height: 122px; width: 578px’><table
class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>yyyyy</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td
class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>yyyyy</td><td class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table><table class=’tblMain’ cellpadding=’0′ border=’0′
width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND2′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height: 122px; width: 578px’><table class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td
class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>test3</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>test</td><td
class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND3′ style=’background-image: url(images/newsBack.png);
background-repeat: no-repeat;height: 122px; width: 578px’><table class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>hhhh</td><td class=’W25′></td></tr><tr><td
class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>hhhhh</td><td class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table></div><div
Id=’NewsDisplayByMonth1′ style=’display:none’><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND4′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height: 122px; width: 578px’><table
class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>test</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td
class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>test</td><td class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table><table class=’tblMain’ cellpadding=’0′ border=’0′
width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND5′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height: 122px; width: 578px’><table class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td
class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>University of Colorado, Colorado Springs selects EMS</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left
clsTextDesc11 Pad5′ style=’width: 90%’>With EMS’ simulation management solution, students at University of Colorado, Colorado Springs’ Beth-El College of Nursing will have the opportunity to practice interactive and reflective learning through digitally recorded
simulated events, debriefi</td><td class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND6′ style=’background-image:
url(images/newsBack.png); background-repeat: no-repeat;height: 122px; width: 578px’><table class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>Oklahoma State
University Center for Health selects EMS</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>Oklahoma State University
Center for Health, a current customer, will expand their use of EMS solutions to support their growing center.</td><td class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table><table class=’tblMain’
cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND7′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height: 122px; width: 578px’><table class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td
class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>San Jose State University selects EMS</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td
class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>Current customer San Jose State University School of Nursing selects additional EMS simulation management technologies for the expansion of its Clinical Simulation Lab.</td><td class=’W25′></td></tr></div></table></td><td
class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND8′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height:
122px; width: 578px’><table class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>Hennepin County Medical Center selects EMS</td><td class=’W25′></td></tr><tr><td
class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>Hennepin County Medical Center’s medical personnel will improve their clinical and technical skills, and
strengthen behavioral skills such as leadership, communication, and teamwork, with EMS’ simulation management and audio-video recording solution.</td><td class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table></div><div
Id=’NewsDisplayByMonth1′ style=’display:none’><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND9′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height: 122px; width: 578px’><table
class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>Madonna University selects EMS</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td
class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>Madonna University’s new nursing lab includes 5 simulation rooms, a skills practice area, and simulation management technology from EMS, which will
bring the advantages of simulation to the undergraduate and graduate programs.</td><td class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td
class=’clsTD_V_Left’<div Id=’ND10′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height: 122px; width: 578px’><table class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td
class=’clsTD_V_Left clsText clsBold’>Regina Qu’Appelle Health Region selects EMS</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width:
90%’>The Regina Qu’Appelle Health Region is the largest tertiary health care system in southern Saskatchewan (Canada). EMS’ integrated audio-video and simulation center management technology will help to optimize its training and inter-professional patien</td><td
class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table></div><div Id=’NewsDisplayByMonth1′ style=’display:none’><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div
Id=’ND11′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height: 122px; width: 578px’><table class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left
clsText clsBold’>Stillman College Nursing Department selects EMS</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>Stillman
College nursing students will be able to enhance their user experience and exercise sound judgment and critical thinking with EMS’ SimScenarios.</td><td class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table></div><div
Id=’NewsDisplayByMonth1′ style=’display:none’><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND12′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height: 122px; width: 578px’><table
class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>EMS Ranked a Top Technology Employer</td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’H5′></td><td
class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>EMS ranked #18 on Philadelphia’s Top Technology Employers 2011 list published by the Philadelphia Business Journal.</td><td class=’W25′></td></tr></div></table></td><td
class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table><table class=’tblMain’ cellpadding=’0′ border=’0′ width=’100%’><tr><td class=’clsTD_V_Left’<div Id=’ND13′ style=’background-image: url(images/newsBack.png); background-repeat: no-repeat;height:
122px; width: 578px’><table class=’tblMain’><tr><td class=’W25′></td><td class=’H10′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsText clsBold’>McClennan Community College selects EMS</td><td class=’W25′></td></tr><tr><td
class=’W25′></td><td class=’H5′></td><td class=’W25′></td></tr><tr><td class=’W25′></td><td class=’clsTD_V_Left clsTextDesc11 Pad5′ style=’width: 90%’>The Paramedicine Program at McLennan Community College will use EMS simulation management software and audio-visual
technology at its new Emergency Services Education Center (ESEC). Equipped with a simulated ambulance, ESEC will serve MCC students, a</td><td class=’W25′></td></tr></div></table></td><td class=’W5′></td></tr><tr><td class=’H5′ colspan=’2′></td></tr></table></div></td>
</td>
</tr>
</table>


thanks in advance

[RESOLVED]linkbutton value does not convert to integer

hi

i have a repeater in which i have2 linkbutton  linkbutton 

i wan to convert 1st linkbutton  value and show on the linkbutton

but it gives me error when i convert linkbutton value 

Unable to cast object of type ‘System.Web.UI.WebControls.LinkButton’ to type ‘System.IConvertible’.

mycode is :

protected void linklike_Click(object sender, EventArgs e)
{
LinkButton b = (LinkButton)sender;
RepeaterItem item = (RepeaterItem)b.NamingContainer;

if (item != null)
{
int index = item.ItemIndex;
HiddenField Pid = (HiddenField)item.FindControl("pid");
int no = Convert.ToInt16(Pid.Value.TrimStart());
LinkButton totallikes = (LinkButton)item.FindControl("lblnooflikes");
int no1 = Convert.ToInt16(totallikes);
connection = new SqlConnection(strcon);
command = new SqlCommand("SpLikeAndUnLike", connection);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.AddWithValue("@PostId", Pid );
command.Parameters.AddWithValue("@RankId", Convert .ToInt16 (Session ["RankId"]));
command.Parameters.AddWithValue("@TotalCount",no1 );
SqlParameter output = new SqlParameter("@Out", SqlDbType.Int);
output.Direction = ParameterDirection.Output;
command.Parameters.Add(output);
connection.Open();
command.ExecuteNonQuery();
int outval = (int)output.Value;
connection.Close();
if (outval == 1)
{

b.Text = "Like";
}
else if (outval == 2)
{
b.Text = "UnLike";
}

}
}

please help me

thanks

You can’t convert a LinkButton to an integer.  You can convert the Text like this…

int no1 = Convert.ToInt16(totallikes.Text);

Or you can use a CommandArgument…

<asp:LinkButton ID="totallikes" runat="server" CommandArgument="5"></asp:LinkButton>
int no1 = Convert.ToInt16(totallikes.CommandArgument);

Matt