ImageButton does'nt fire OnItemCommand in repeater control - asp.net

everyone!
I'm writing repeater control on my web-page. After I added data paging for repeater I have got problem:
ImageButton does'nt fire any more OnItemCommand event of repeater. Why?
Here, is part of markup code:
<asp:Repeater ID="PartsRepeater" runat="server"
OnItemCommand="partsRepeater_ItemCommand"
OnItemDataBound="partsRepeaterItem_Bound">
<HeaderTemplate>
<table rules="all" cellspacing="0" style="border-color: rgb(31, 77, 48);
border-style: solid; width: 100%; border-collapse: collapse;">
<tr >
<td style="width: 92%;">
<table cellspacing="0" border="0" style="border-color: rgb(31, 77, 48); border-style: solid;
width: 100%; border-collapse: collapse;">
<tr style="background-color: #1f4d30; color: white;">
<td style="width: 10%;">
<asp:Label runat="server" Text="Name" ID="lblName">
</asp:Label>
</td>
<td style="width: 10%;">
<asp:Label runat="server" Text="Number" ID="Label64">
</asp:Label>
</td>
<td style="width: 10%;">
<asp:Label runat="server" Text="Category" ID="Label65">
</asp:Label>
</td>
<td style="width: 20%;">
<asp:Label runat="server" Text="Description" ID="Label66">
</asp:Label>
</td>
<td style="width: 20%;">
<asp:Label runat="server" Text="Models" ID="Label67">
</asp:Label>
</td>
<td style="width: 5%;">
<asp:Label runat="server" Text="Price" ID="Label68">
</asp:Label>
</td>
<td style="width: 5%;">
<asp:Label runat="server" Text="A Qty" ID="Label69">
</asp:Label>
</td>
<td style="width: 5%;">
<asp:Label runat="server" Text="B Qty" ID="Label70">
</asp:Label>
</td>
<td style="width: 5%;">
<asp:Label runat="server" Text="Actual Qty" ID="Label71">
</asp:Label>
</td>
<td style="width: 5%;">
<asp:Label runat="server" Text="Total Qty" ID="Label72">
</asp:Label>
</td>
<td style="width: 5%;" >
</td>
</tr>
</table>
</td>
<td style="width: 8%;" >
</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="border-color: #1f4d30;"
>
<td style="width: 92%;">
<table border="0" cellspacing="0" class="PartsRepeater_InnerTable">
<tr class="PartsRepeater_InnerTable">
<td style="cursor: pointer; width: 10%;" class="PartsRepeater_InnerTable">
<asp:HiddenField runat="server" ID="PartID" Value='<%# Bind("PartID") %>' Visible="false" />
<asp:LinkButton runat="server" ID="Label52" Text='<%#Eval("Name").ToString()%>' CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 10%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="Label45" runat="server" Text='<%#Eval("Number").ToString().ToUpper()%>'
CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 20%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="Label46" runat="server" Text='<%#Eval("Category").ToString()%>'
CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 20%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="Label47" runat="server" Text='<%# GetPartDescr((String)Eval("Description"))%>'
CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 5%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="Label48" runat="server" Text=' <%# GetPartDescr((String)Eval("ModelName")) %>'
CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="Label49" runat="server" Text='<%# GetPrice(Eval("Price").ToString(), Eval("sPrice").ToString(), Eval("Price3").ToString())%>'
CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="lblAQTY" runat="server" Text=' <%#Eval("AGradeQty").ToString()%>'
CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="lblBQty" runat="server" Text=' <%# int.Parse(Eval("QtyInStock").ToString()) - int.Parse(Eval("AGradeQty").ToString())%>'
CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="lblActualQTY" runat="server" Text=' <%#Eval("ActualQty").ToString()%>'
CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 4%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="Label60" runat="server" Text='<%#Eval("QtyInStock").ToString()%>'
CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
</tr>
<tr >
<td colspan="15" style="cursor: pointer; width: 5%;">
<asp:LinkButton ID="Label63" runat="server" Text='<%#Eval("priceModificationDate").ToString()%>'
Font-Size="Smaller" CommandArgument='<%# Eval("PartID") %>'>
</asp:LinkButton>
</td>
</tr>
</table>
</td>
<td style="width: 8%">
<table>
<tr>
<td style="cursor: pointer; width: 50%;" class="PartsRepeater_InnerTable">
<asp:ImageButton ID="btnEdit" runat="server" ImageUrl="~/Images/edit.png" CausesValidation="False"
CommandName="editRow" CommandArgument='<%# Eval("PartID") %>' OnClientClick='SaveScrollPositions'>
</asp:ImageButton>
</td>
<td style="cursor: pointer; width: 50%;">
<asp:ImageButton ID="btnDelete" runat="server" OnClientClick='<%# GetConfirmMessage(Eval("Name"))%>'
ImageUrl="~/Images/delete.png" CausesValidation="False" CommandName="Delete"
CommandArgument='<%# Eval("PartID") %>'></asp:ImageButton>
</td>
</tr>
</table>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>

I've tried nany ways to solve this problem and solved it so:
I just replace ImageButton with linkButton with image:
Part og code:
<td style="cursor: pointer; width: 50%;" class="PartsRepeater_InnerTable">
<asp:LinkButton ID="btnEdit" runat="server" CausesValidation="false" CommandName="editRow"
CommandArgument='<%# Eval("PartID") %>' OnClientClick='SaveScrollPositions'>
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/edit.png" />
</asp:LinkButton>
</td>
<td style="cursor: pointer; width: 50%;">
<asp:LinkButton ID="btnDelete" runat="server" CausesValidation="false" CommandName="Delete"
CommandArgument='<%# Eval("PartID") %>' OnClientClick='<%# GetConfirmMessage(Eval("Name"))%>'>
<asp:Image ID="Image2" runat="server" ImageUrl="~/Images/delete.png" />
</asp:LinkButton>
</td>
For more see: http://weblogs.asp.net/justinsaraceno/archive/2008/11/05/linkbutton-with-image-and-text.aspx

Sorry I don't have a more specific answer, but it has something to do with ViewState on the repeater and rebinding the repeater on Postback.
Apparently, when the postback occurs and you rebind the repeater, it loses some event binding and instead of running the OnCommand, it treats it as if it's a first page load for ImageButton. AFAIK it only happens on ImageButton and not LinkButton or Button.

Put this in code behind it will surely work
if (!Page.IsPostBack)
{
REPEATERDATABIND(); // Bind method
}

Related

Listview is losing data on postback ASP.Net

I am trying to update the whole list by once by using a button but in code behind I am losing the data of the list items it returns null although it has the items. Please help me in this manner. my code is below
aspx
<asp:ListView ID="ProjectsList" runat="server" DataKeyNames="ProjectId" DataSourceID="EntityDataSource1" ViewStateMode="Enabled">
<AlternatingItemTemplate>
<tr style="background-color: #FFF8DC;">
<td><asp:Label ID="ProjectIdLabel" runat="server" Text='<%# Eval("ProjectId") %>' /></td>
<td><asp:Label ID="SchoolIdLabel" runat="server" Text='<%# Eval("SchoolId") %>' /></td>
<td><asp:Label ID="FairIdLabel" runat="server" Text='<%# Eval("FairId") %>' /></td>
<td><asp:Label ID="CategoryIdLabel" runat="server" Text='<%# Eval("CategoryId") %>' /></td>
<td><asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' /></td>
<td><asp:Label ID="BalanceLabel" runat="server" Text='<%# Eval("Balance") %>' /></td>
<td><asp:CheckBox ID="FinalistCheckBox" runat="server" Checked='<%# Eval("Finalist") %>' Enabled="true" /></td>
<td><asp:Label ID="ProjectStatusLabel" runat="server" Text='<%# Eval("ProjectStatus") %>' /></td>
</tr>
</AlternatingItemTemplate>
<ItemTemplate>
<tr style="background-color: #DCDCDC; color: #000000;">
<td><asp:Label ID="ProjectIdLabel" runat="server" Text='<%# Eval("ProjectId") %>' /></td>
<td>asp:Label ID="SchoolIdLabel" runat="server" Text='<%# Eval("SchoolId") %>' /></td>
<td><asp:Label ID="FairIdLabel" runat="server" Text='<%# Eval("FairId") %>' /></td>
<td><asp:Label ID="CategoryIdLabel" runat="server" Text='<%# Eval("CategoryId") %>' /></td>
<td><asp:Label ID="TitleLabel" runat="server" Text='<%# Eval("Title") %>' /></td>
<td><asp:Label ID="BalanceLabel" runat="server" Text='<%# Eval("Balance") %>' /></td>
<td><asp:CheckBox ID="FinalistCheckBox" runat="server" Checked='<%# Eval("Finalist") %>' Enabled="true" /></td>
<td><asp:Label ID="ProjectStatusLabel" runat="server" Text='<%# Eval("ProjectStatus") %>' /></td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF; border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px; font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color: #DCDCDC; color: #000000;">
<th runat="server">ProjectId</th>
<th id="Th1" runat="server">SchoolId</th>
<th id="Th2" runat="server">FairId</th>
<th id="Th3" runat="server">CategoryId</th>
<th runat="server">Title</th>
<th id="Th4" runat="server">Balance</th>
<th runat="server">Finalist</th>
<th runat="server">ProjectStatus</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="text-align: center; background-color: #CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;"></td>
</tr>
</table>
</LayoutTemplate>
</asp:ListView>
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=MyEntity" DefaultContainerName="MyEntity" EnableFlattening="False" EnableUpdate="True" EntitySetName="Projects">
</asp:EntityDataSource>
<asp:Button ID="FinalistButton" runat="server" Text="Finalist" OnClick="FinalistButton_Click" CssClass="imageButtonStyle" />
and my aspx.cs...
protected void FinalistButton_Click(object sender, EventArgs e)
{
//here I can have all the items but there is no value
foreach (ListViewItem item in ProjectsList.Items)
{
if (item.ItemType == ListViewItemType.DataItem)
{
CheckBox final = (CheckBox)item.FindControl("Finalist");
TextBox proidText = (TextBox)item.FindControl("ProjectId");
int proId = Convert.ToInt32(proidText.Text);
if (final.Checked)
{
//some code
}
}
}
}
To insert or update data, the templates < InsertItemTemplate> and/or < EditItemTemplate> should be included, maybe they're missing. Templates < ItemTemplate> and < AlternateItemTemplate> are just used to show data. To change templates, add some command buttons. And you use Bind instead of Eval
You have a walkthrough at the following link, not very good, though. Maybe you can find a better example.
http://msdn.microsoft.com/en-us/library/bb515103.aspx

Changing the color of a selected row in an ASP.NET Repeater

I have an ASP.NET repeater with an ImageButton. My ImageButton has an OnCommand event.
My goal: When I click the ImageButton, I would like the color of the selected row to change.
Here is an excerpt from my ASP.NET code. Can anyone help me?
<asp:Repeater ID="RepeaterID" runat="server" OnItemCommand="rpt_ItemCommand">
<HeaderTemplate>
<table cellpadding="0" cellspacing="0" id="table1">
<thead>
<tr>
<th>
<asp:Label ID="lbl_refCode" runat="server"></asp:Label>
</th>
<th style="width: 25px"></th>
</tr>
</thead>
</table>
</HeaderTemplate>
<ItemTemplate>
<tr id="row" runat="server">
<td style="width: 50px;">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("RefCode") %>'</asp:Label>
</td>
<td style="width: 25px;">
<asp:ImageButton ImageUrl="Icons/edit.png" CommandArgument='<%# Eval("ID") %>' CommandName="Edit" ID="ImgEdit" OnCommand="Manage" runat="server">
</asp:ImageButton>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr id="row" runat="server">
<td style="width: 50px;">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("RefCode") %>' </asp:Label>
</td>
<td style="width: 25px;">
<asp:ImageButton ImageUrl="Icons/edit.png" CommandArgument='<%# Eval("ID") %>' CommandName="Edit" ID="ImgEdit" OnCommand="Manage" runat="server">
</asp:ImageButton>
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</Table>
</FooterTemplate>
</asp:Repeater>
Try using the OnItemCommand event of the Repeater instead of the LinkButton's OnCommand event. The RepeaterCommandEventArgs parameter will give you access to the whole Item instead of just the LinkButton, and you can set the background color of the table row.
<asp:Repeater ID="RepeaterID" runat="server" OnItemCommand="rpt_ItemCommand">
<HeaderTemplate>
<table cellpadding="0" cellspacing="0" id="table1">
<thead>
<tr>
<th>
<asp:Label ID="lbl_refCode" runat="server" </asp:Label>
</th>
<th style="width: 25px"></th>
</tr>
</thead>
</HeaderTemplate>
<ItemTemplate>
<tr id="row" runat="server">
<td style="width: 50px;">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("RefCode") %>' </asp:Label>
</td>
<td style="width: 25px;">
<asp:ImageButton ImageUrl="Icons/edit.png" CommandArgument='<%# Eval("ID") %>' CommandName="Edit" ID="ImgEdit" runat="server">
</asp:ImageButton>
</td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr id="row" runat="server">
<td style="width: 50px;">
<asp:Label ID="Label2" runat="server" Text='<%# Eval("RefCode") %>' </asp:Label>
</td>
<td style="width: 25px;">
<asp:ImageButton ImageUrl="Icons/edit.png" CommandArgument='<%# Eval("ID") %>' CommandName="Edit" ID="ImgEdit" runat="server">
</asp:ImageButton>
</td>
</tr>
</AlternatingItemTemplate>
<FooterTemplate>
</Table>
</FooterTemplate>
</asp:Repeater>
protected void rpt_ItemCommand(object source, RepeaterCommandEventArgs e)
{
if (e.CommandName.Equals("Edit"))
{
HtmlTableRow newRow = e.Item.FindControl("row") as HtmlTableRow;
if (newRow != null)
newRow.BgColor = "#CCCCCC";
}
}
Note that in the ItemTemplate the table row has an id so it can be found in the ItemCommand argument.

Modalpopup wont close when dropdown is selected

I've been having this odd issue with modal popups. For some reason when I choose a dropdown item my update button wont fire a click event. but then I leave the dropdown at their default values the update button works just fine.
here's my aspx page code
<asp:Button ID="Button1" CssClass="hide" runat="server" Text="Button" />
<ajaxToolkit:ModalPopupExtender runat="server" ID="cfPopUp" PopupControlID="Panel4"
TargetControlID="Button1" OkControlID="cfUpdateBtn" CancelControlID="cfCancelBtn" />
<asp:Panel ID="Panel4" runat="server" CssClass="modalPopup">
<asp:UpdatePanel ID="UpdatePanel2" runat="Server">
<ContentTemplate>
<asp:Panel ID="Panel13" CssClass="" runat="server">
<asp:Panel ID="Panel14" CssClass="" runat="server">
<div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;">
<asp:Label ID="Label25" Width="200px" runat="server" Text="Health and Safety Net" /><div
class="seperator">
</div>
<table class="style143">
<tr>
<td class="style185">
<asp:Label ID="cfCategorylbl" runat="server" Text="Category:"></asp:Label>:
</td>
<td>
<asp:DropDownList ID="cbFactors_Categories" runat="server" Width="350px" Font-Names="Tahoma"
Font-Size="Small" ForeColor="DimGray" Height="24px" CssClass="style75">
</asp:DropDownList>
<ajaxToolkit:CascadingDropDown ID="CascadingDropDown3" runat="server" TargetControlID="cbFactors_Categories"
Category="categories" ServiceMethod="getCategory" ServicePath="~/2012/IrSubmitWebService.asmx"
PromptText="Select Category" />
</td>
<td align="center" rowspan="3" valign="top">
<asp:Label ID="lblFactor_ID" runat="server" Font-Names="Tahoma" Font-Size="Small"
ForeColor="DimGray" Style="font-style: italic" TabIndex="56"></asp:Label>
<cc1:DynamicPopulateExtender ID="lblFactor_ID_DynamicPopulateExtender" runat="server"
Enabled="True" TargetControlID="lblFactor_ID" BehaviorID="dp1" ServiceMethod="getFactorID"
ServicePath="~/2012/IrSubmitWebService.asmx">
</cc1:DynamicPopulateExtender>
<hr class="style157" />
<asp:Label ID="cfID" runat="server" Font-Names="Tahoma" Font-Size="Small" ForeColor="DimGray"
Style="font-style: italic" Width="400px" TabIndex="57"></asp:Label>
</td>
</tr>
<tr>
<td class="style185">
<asp:Label ID="cfTypeslbl" runat="server" Text="Type:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="cbFactors_Types" runat="server" ForeColor="DimGray" Height="24px"
TabIndex="54" Width="350px" Font-Names="Tahoma" Font-Size="Small" CssClass="style75">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cbFactors_Types_CascadingDropDown" runat="server"
TargetControlID="cbFactors_Types" ParentControlID="cbFactors_Categories" Category="type"
ServiceMethod="getTypeofAction" ServicePath="~/2012/IrSubmitWebService.asmx"
PromptText="Select Type">
</cc1:CascadingDropDown>
</td>
</tr>
<tr>
<td class="style185">
<asp:Label ID="cfFactorslbl" runat="server" Text="Factor:"></asp:Label>
</td>
<td>
<asp:DropDownList ID="cbFactors_Factors" runat="server" ForeColor="DimGray" Height="24px"
TabIndex="55" Width="350px" Font-Names="tahoma" Font-Size="Small" CssClass="style75">
</asp:DropDownList>
<cc1:CascadingDropDown ID="cbFactors_Factors_CascadingDropDown" runat="server"
TargetControlID="cbFactors_Factors" ParentControlID="cbFactors_Types" Category="category"
ServiceMethod="getFactor" ServicePath="~/2012/IrSubmitWebService.asmx" PromptText="Select Factor">
</cc1:CascadingDropDown>
</td>
</tr>
<tr>
<td class="style185">
<asp:Label Text="Justification:" ID="cfJustificationlbl" runat="server"></asp:Label>
</td>
<td colspan="2">
<asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="29px"
Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine"
ToolTip="Provide a justification for this factor." Width="775px" Font-Names="Tahoma"
Font-Size="Small"></asp:TextBox>
</td>
</tr>
</table>
<br />
<div style="text-align: center">
<asp:Button CausesValidation="false" ID="cfUpdateBtn" runat="server"
Text="Update" CssClass="button" /><span style="margin-left: 10px"><asp:Button CausesValidation="false"
ID="cfCancelBtn" runat="server" Text="Cancel" CssClass="button" /></span></div>
</div>
</asp:Panel>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
and my code behind for my update (it just closes the popup)
Protected Sub cfUpdateBtn_Click(sender As Object, e As EventArgs) Handles cfUpdateBtn.Click
cfPopUp.Hide()
End Sub
For the life of me I can't figure out why the update button wont work when the dropdowns are not the default value.
Thanks for your help guys
The possible reason may be you are binding your dropdownlist with a webservice. Whenever you click to an item on dropdownlist webservice may be called. If webservice is called then may be your page again loaded ? I don't know the exact reason why it is not working. You have to check the service behavior what happened when the service is called.
I basically rebuilt my modal popup and update panel like so
<asp:Panel ID="pnlEditPopup" runat="server" CssClass="modalPopup">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:Panel ID="pnlEditPopupContent" runat="server">
<div style="padding: 10px; border: 3px solid black; background-color: White; color: Black;">
<table cellpadding="0" cellspacing="4" border="0">
<tr>
<td class="name">Category:</td>
<td class="value">
<asp:DropDownList id="ddCat" runat="server">
<asp:listitem value="">No Selection</asp:listitem>
<asp:listitem value="Action">Action</asp:listitem>
<asp:listitem value="Worksite">Worksite</asp:listitem>
<asp:listitem value="Human Factors">Human Factors</asp:listitem>
<asp:listitem value="System Factors">System Factors</asp:listitem>
</asp:DropDownList>
</td>
</tr>
<tr>
<td class="name">Type:</td>
<td class="value">
<asp:DropDownList id="ddType" runat="server" />
<ajaxToolkit:CascadingDropDown ID="ccType" runat="server"
TargetControlID="ddType"
ParentControlID="ddCat"
PromptText="No Selection"
LoadingText="Please Wait..."
ServicePath="~/2012/IrSubmitWebService.asmx"
ServiceMethod="getTypeofAction"
Category="Other"
/>
</td>
</tr>
<tr>
<td class="name">Factor:</td>
<td class="value">
<asp:DropDownList id="ddfactor" runat="server" />
<ajaxToolkit:CascadingDropDown ID="ccFactor" runat="server"
TargetControlID="ddfactor"
ParentControlID="ddType"
PromptText="No Selection"
LoadingText="Please Wait..."
ServicePath="~/2012/IrSubmitWebService.asmx"
ServiceMethod="getFactor"
Category="Other"
/>
</td>
</tr>
<tr>
<td>
Justification:
<asp:Label ID="factorID" runat="server" Visible="false"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtJustification" runat="server" ForeColor="DimGray" Height="100px"
Style="font-family: Tahoma; font-size: small" TabIndex="56" TextMode="MultiLine"
ToolTip="Provide a justification for this factor." Width="300px" Font-Names="Tahoma"
Font-Size="Small"></asp:TextBox>
</td>
</tr>
<tr>
<td>
Factor ID<br />
and Description:
</td>
<td>
<asp:Label ID="factor_id_Desc" runat="server" Width="300px" Font-Names="Tahoma" Font-Size="Small"
ForeColor="DimGray" TabIndex="56"></asp:Label>
<cc1:DynamicPopulateExtender ID="DynamicPopulateExtender1" runat="server"
Enabled="True" TargetControlID="factor_id_Desc" BehaviorID="dp1" ServiceMethod="getFactorID"
ServicePath="~/2012/IrSubmitWebService.asmx">
</cc1:DynamicPopulateExtender>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<asp:Button ID="btnOkEditPopup" runat="server" Text="Ok" CssClass="button"/>
<span style="margin-left:10px"><asp:button id="btnCancelEditPopup" runat="server" text="Cancel" CssClass="button"/></span>
</td>
</tr>
</table>
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="mpeEdit" runat="server"
TargetControlID="btnOpenEditPopup"
PopupControlID="pnlEditPopup"
/>
Fixed my issue. I still dont know why it wasn't working when I asked the question but I was able to solve it. Thanks to all who looked into it for me.

How can I relocate ListView

I have a ListView in the design view,,but I cant move it with an absolute css attribute.
Is there a way to move it on a page?
<asp:ListView ID="ListView1" runat="server" DataKeyNames="MessageID"
DataSourceID="SqlDataSource1" onitemcommand="ListView1_ItemCommand"
style="z-index: 1; left: 452px; top: 429px; position: absolute; height: 271px; width: 221px; margin-top: 0px">
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr runat="server" style="background-color: #FFFBD6;color: #333333;">
<th runat="server">
MessageTitle</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server"
style="text-align: center;background-color: #FFCC66;font-family: Verdana, Arial, Helvetica, sans-serif;color: #333333;">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True"
ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #FAFAD2;color: #284775;">
<td>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Select">'<%# Eval("MessageTitle") %>'</asp:LinkButton>
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color: #FFCC66;color: #000080;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update"
Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Cancel" />
</td>
<td>
<asp:TextBox ID="MessageTitleTextBox" runat="server"
Text='<%# Bind("MessageTitle") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table runat="server"
style="background-color: #FFFFFF;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;">
<tr>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert"
Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel"
Text="Clear" />
</td>
<td>
<asp:TextBox ID="MessageTitleTextBox" runat="server"
Text='<%# Bind("MessageTitle") %>' />
</td>
<td>
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color: #FFFBD6;color: #333333;">
<td>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Select" >'<%# Eval("MessageTitle") %>'</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
<SelectedItemTemplate>
<tr style="background-color: #FFCC66;font-weight: bold;color: #000080;">
<td>
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="Select">'<%# Eval("MessageTitle") %>'</asp:LinkButton>
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:CP_AllQuestionsAnswered %>"
SelectCommand="GetMessagesTitles" SelectCommandType="StoredProcedure">
<SelectParameters>
<asp:Parameter Name="Name" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
What a problem:
div.ListView1
{
position: absolute;
left: 100;
top: 100;
}
<asp:ListView runat="server" ID="ListView1" ItemPlaceholderID="itemPlaceholder">
<LayoutTemplate>
<div class="ListView1">
<asp:PlaceHolder runat="server" ID="itemPlaceholder" />
</div>
</LayoutTemplate>
<ItemTemplate>
<%# Container.DataItem.ToString() %>
<br />
</ItemTemplate>
</asp:ListView>
Ok, your problem is that you set ListView's style attribute when you need specify this attribute for the table in the LayoutTemplate.

Failing to move a listView with css

I am trying to move a list view with css...It moves to the left when i give it some value in the div tag in the layout template..but when I run it in the browser what I get is a listView sitting in the same place.. here is the code with the two problematic listviews:
<%# Page Title="" Language="C#" MasterPageFile="~/CP.master" AutoEventWireup="true"
CodeFile="Spam.aspx.cs" Inherits="Moderator_Spam" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<br />
<asp:Label ID="CommentHeader" runat="server" Text="הודעות ספאם של פוסטים"></asp:Label>
<br />
<br />
<asp:ListView ID="ListView1" runat="server" DataKeyNames="CommentsID" DataSourceID="SqlDataSource1"
Style="top: 433px; left: -56px">
<AlternatingItemTemplate>
<tr style="background-color: #FFF8DC;">
<td>
<asp:Label ID="CommentsLabel" runat="server" Text='<%# Eval("Comments") %>' />
</td>
<td>
<asp:Button ID="DeleteComment_Btn" runat="server" Text="מחק" CommandName="Delete" />
<asp:Button ID="IgnoreComment_Btn" runat="server" Text="התעלם" CommandName="Update" />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color: #008A8C; color: #FFFFFF;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="CommentsTextBox" runat="server" Text='<%# Bind("Comments") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server" style="background-color: #FFFFFF; border-collapse: collapse;
border-color: #999999; border-style: none; border-width: 1px;">
<tr>
<td>
אין ספאם
</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="CommentsTextBox" runat="server" Text='<%# Bind("Comments") %>' />
</td>
<td>
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color: #DCDCDC; color: #000000;">
<td>
<asp:Label ID="CommentsLabel" runat="server" Text='<%# Eval("Comments") %>' />
</td>
<td>
<asp:Button ID="DeleteComment_Btn" runat="server" Text="מחק" CommandName="Delete" />
<asp:Button ID="IgnoreComment_Btn" runat="server" Text="התעלם" CommandName="Update" />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<div style="position: absolute; left: 0px">
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;
border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;
font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr id="Tr2" runat="server" style="background-color: #DCDCDC; color: #000000;">
<th id="Th1" runat="server">
Comments
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server" style="text-align: center; background-color: #CCCCCC;
font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</div>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color: #008A8C; font-weight: bold; color: #FFFFFF;">
<td>
<asp:Label ID="CommentsLabel" runat="server" Text='<%# Eval("Comments") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CP_AllQuestionsAnswered %>"
DeleteCommand="ModeratorSpamDeleteComment" DeleteCommandType="StoredProcedure"
SelectCommand="ModeratorSpamComments" SelectCommandType="StoredProcedure" UpdateCommand="ModeratorIgnoreSpamComment"
UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="CommentsID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="CommentsID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
<br />
<asp:Label ID="Label1" runat="server" Text="הודעות ספאם של אשכולים"></asp:Label>
<br />
<asp:ListView ID="ListView2" runat="server" DataKeyNames="ThreadsID" DataSourceID="SqlDataSource2"
Style="z-index: 1; left: 452px; top: 753px; position: absolute; height: 381px;
width: 221px">
<AlternatingItemTemplate>
<tr style="background-color: #FFF8DC;">
<td>
<asp:Label ID="ThreadTitleLabel" runat="server" Text='<%# Eval("ThreadTitle") %>' />
</td>
<td>
<asp:Button ID="DeleteThread_Btn" runat="server" Text="מחק" CommandName="Delete" />
<asp:Button ID="IgnoreThread_Btn" runat="server" Text="התעלם" CommandName="Update" />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color: #008A8C; color: #FFFFFF;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="ThreadTitleTextBox" runat="server" Text='<%# Eval("ThreadTitle") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table id="Table3" runat="server" style="background-color: #FFFFFF; border-collapse: collapse;
border-color: #999999; border-style: none; border-width: 1px;">
<tr>
<td>
אין ספאם
</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="ThreadTitleTextBox" runat="server" Text='<%# Bind("ThreadTitle") %>' />
</td>
<td>
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color: #DCDCDC; color: #000000;">
<td>
<asp:Label ID="ThreadTitleLabel" runat="server" Text='<%# Eval("ThreadTitle") %>' />
</td>
<td>
<asp:Button ID="DeleteThread_Btn" runat="server" Text="מחק" CommandName="Delete" />
<asp:Button ID="IgnoreThread_Btn" runat="server" Text="התעלם" CommandName="Update" />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table id="Table4" runat="server">
<tr id="Tr4" runat="server">
<td id="Td3" runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;
border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;
font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr id="Tr5" runat="server" style="background-color: #DCDCDC; color: #000000;">
<th id="Th2" runat="server">
ThreadTitle
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr6" runat="server">
<td id="Td4" runat="server" style="text-align: center; background-color: #CCCCCC;
font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color: #008A8C; font-weight: bold; color: #FFFFFF;">
<td>
<asp:Label ID="ThreadTitleLabel" runat="server" Text='<%# Eval("ThreadTitle") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CP_AllQuestionsAnswered %>"
DeleteCommand="ModeratorSpamDeleteThread" DeleteCommandType="StoredProcedure"
SelectCommand="ModeratorSpamThread" SelectCommandType="StoredProcedure" UpdateCommand="ModeratorSpamIgnoreThread"
UpdateCommandType="StoredProcedure">
<DeleteParameters>
<asp:Parameter Name="ThreadsID" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="ThreadsID" Type="Int32" />
</UpdateParameters>
</asp:SqlDataSource>
</asp:Content>
I suppose your error is that you try to set Style on a ListView control directly. The listView control hasn't Style property. Actually there is element this style may be applied on. Move styles from ListViews to the first table in LayoutTemplate.
Put the list view inside a div and give it a margin-left
<asp:ListView ID="ListView1" runat="server" DataKeyNames="CommentsID" DataSourceID="SqlDataSource1"
Style="top: 433px; left: -56px">
<AlternatingItemTemplate>
<tr style="background-color: #FFF8DC;">
<td>
<asp:Label ID="CommentsLabel" runat="server" Text='<%# Eval("Comments") %>' />
</td>
<td>
<asp:Button ID="DeleteComment_Btn" runat="server" Text="מחק" CommandName="Delete" />
<asp:Button ID="IgnoreComment_Btn" runat="server" Text="התעלם" CommandName="Update" />
</td>
</tr>
</AlternatingItemTemplate>
<EditItemTemplate>
<tr style="background-color: #008A8C; color: #FFFFFF;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" />
</td>
<td>
<asp:TextBox ID="CommentsTextBox" runat="server" Text='<%# Bind("Comments") %>' />
</td>
</tr>
</EditItemTemplate>
<EmptyDataTemplate>
<table id="Table1" runat="server" style="background-color: #FFFFFF; border-collapse: collapse;
border-color: #999999; border-style: none; border-width: 1px;">
<tr>
<td>
אין ספאם
</td>
</tr>
</table>
</EmptyDataTemplate>
<InsertItemTemplate>
<tr style="">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" />
</td>
<td>
<asp:TextBox ID="CommentsTextBox" runat="server" Text='<%# Bind("Comments") %>' />
</td>
<td>
</td>
</tr>
</InsertItemTemplate>
<ItemTemplate>
<tr style="background-color: #DCDCDC; color: #000000;">
<td>
<asp:Label ID="CommentsLabel" runat="server" Text='<%# Eval("Comments") %>' />
</td>
<td>
<asp:Button ID="DeleteComment_Btn" runat="server" Text="מחק" CommandName="Delete" />
<asp:Button ID="IgnoreComment_Btn" runat="server" Text="התעלם" CommandName="Update" />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<div style="position: absolute; left: 0px">
<table id="Table2" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table id="itemPlaceholderContainer" runat="server" border="1" style="background-color: #FFFFFF;
border-collapse: collapse; border-color: #999999; border-style: none; border-width: 1px;
font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr id="Tr2" runat="server" style="background-color: #DCDCDC; color: #000000;">
<th id="Th1" runat="server">
Comments
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server" style="text-align: center; background-color: #CCCCCC;
font-family: Verdana, Arial, Helvetica, sans-serif; color: #000000;">
<asp:DataPager ID="DataPager1" runat="server">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="True" ShowLastPageButton="True" />
</Fields>
</asp:DataPager>
</td>
</tr>
</table>
</div>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="background-color: #008A8C; font-weight: bold; color: #FFFFFF;">
<td>
<asp:Label ID="CommentsLabel" runat="server" Text='<%# Eval("Comments") %>' />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
</div>

Resources