Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all

I want to fix the button position inside a listview.
My Problem:
When i make the visibility of the button false than the rest elements going to right side so that i am facing the positioning problem .

I want to fix the existence of the button so that i if i invisible the button than the rest element will not come to right side.
XML
<table><tr>
                        <td colspan="7">
                            <asp:ListView ID="lvProjectTestCATMapping" runat="server" OnItemDataBound="lvProjectTestCATMapping_ItemDataBound"
                                DataKeyNames="LEADER_ID, LEADER_NAME, PROJECT_ID, TITLE, TESTCAT_NAME, TESTCAT_IDS, PROJECT_STATUS,STATUS,ACTTECHSTART,ACTTECHEND,TECHSTART,TECHEND"
                                OnPagePropertiesChanged="lvProjectTestCATMapping_PagePropertiesChanged">
                                <LayoutTemplate>
                                    <asp:PlaceHolder ID="itemPlaceholderContainer" runat="server"></asp:PlaceHolder>
                                    <asp:Panel ID="itemPlaceholder" runat="server">
                                    </asp:Panel>
                                </LayoutTemplate>
                                <ItemTemplate>
                                    <table cellpadding="0" cellspacing="2px" style="width: 100%" class="<%# Container.DisplayIndex % 2 == 0 ? "" : "gridViewAlternateRow" %>">
                                        <tr>
                                            <td valign="middle" style="width: 18%">
                                                <asp:HyperLink ID="lnkProjectLead" runat="server" CssClass="hlnkStyle"></asp:HyperLink>
                                            </td>
                                            <td valign="middle" style="width: 25%">
                                                <asp:HyperLink ID="lnkProject" runat="server" CssClass="hlnkStyle"></asp:HyperLink>
                                            </td>
                                            <td valign="middle" style="width: 28%">
                                                <asp:TextBox ID="txtTestCATs" runat="server" Width="280px"></asp:TextBox>
                                                <act:AutoCompleteExtender ID="txtTestCATs_AutoCompleteExtender" EnableCaching="true"
                                                    runat="server" DelimiterCharacters="," Enabled="True" ServicePath="~/GPSWebService.asmx"
                                                    TargetControlID="txtTestCATs" CompletionInterval="500" ServiceMethod="GetMemberName"
                                                    MinimumPrefixLength="1" CompletionListItemCssClass="AutoComplete_ListItem" CompletionListHighlightedItemCssClass="AutoComplete_ListItemHilite"
                                                    FirstRowSelected="True" ShowOnlyCurrentWordInCompletionListItem="true" CompletionListCssClass="AutoComplete_List">
                                                </act:AutoCompleteExtender>
                                                <asp:HiddenField ID="hdnTestCATAssigned" runat="server" />
                                            </td>
                                            <td valign="middle" style="width: 10%">
                                                <asp:Label ID="lblTechStartDate" runat="server" CssClass="lblStyle"></asp:Label>
                                            </td>
                                            <td valign="middle" style="width: 8%">
                                                <asp:Label ID="lblProjectStatus" runat="server" CssClass="lblStyle"></asp:Label>
                                            </td>
                                            <td valign="middle" style="width: 10%">
                                                <asp:Label ID="lblTechEndDate" runat="server" CssClass="lblStyle"></asp:Label>
                                            </td>
                                            <td valign="middle" style="width:1000px">
                                                <asp:Button ID="btnSaveMapping" runat="server" Text="Save" Width="60px" OnClick="btnSaveMapping_Click"/>
                                            </td>
                                        </tr>
                                    </table>
                                </ItemTemplate>
                                <EmptyDataTemplate>
                                    <div style="height: 20px">
                                        <span>Associated Project - TestCAT mappings not found.</span></div>
                                </EmptyDataTemplate>
                            </asp:ListView>
                            <br />
                            <asp:DataPager ID="dpProjectTestCATMapping" runat="server" PageSize="50" PagedControlID="lvProjectTestCATMapping">
                                <Fields>
                                    <asp:NumericPagerField NumericButtonCssClass="linkPageStyle" ButtonCount="10" CurrentPageLabelCssClass="currentPageStyle" />
                                </Fields>
                            </asp:DataPager>
                        </td>
                    </tr></table>


Thanks
Posted
Updated 14-Jun-12 23:33pm
v3

I have two option have a look and let me know if this is fine with you
1. Insert a blank label just beside the button and make it invisible by default , whenever u make the button invisible just make this label which is of same dimension as that of button.

2. Place the different controls in 'td'
eg:
if i have 1 button , 1 label , 1 textbox then :
<table>
<tr>
<td>
    place button over here

<td>
place label over here
</td><td>
place textbox over here
</td>
</tr>
</table>
 
Share this answer
 
v4
Comments
bhagirathimfs 15-Jun-12 3:00am    
i have placed the button in the table but when i do visible=false than the td width reduces, how to fix the width of the td?
sagar wasule 15-Jun-12 3:04am    
you can specify the width of td as well ... check style tag there you can set width
bhagirathimfs 15-Jun-12 3:09am    
i have done this
<table style="width:100%">
<tr>
<td style="width:60px">
<asp:Button ID="Button1" runat="server" Width="60px" Text="Button" /> </td> <td>
<asp:Label ID="Label1" runat="server" Text="Label"> </td>
<td>
<asp:TextBox ID="TextBox1" runat="server"> </td>
</tr>
</table>
sagar wasule 15-Jun-12 3:11am    
Can u tell what is the actual scenario of controls on ur page ?? Provide some code so that we will be more clear about ur doubt
bhagirathimfs 15-Jun-12 5:39am    
i have posted my code please go through it
Use the following code

XML
<table class="width100pc">
            <tr>
                <td class="width50">
                    <asp:Button ID="Button1" runat="server" Text="Button" />
                </td>
                <td>
                    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                </td>
            </tr>
        </table>


and the following in the css class.
C#
.width100pc
{
    width: 100%;
}


C#
td.width50
{
    width: 50px;
}
.width50
{
    width: 49px;
}



Accept the answer if it satisfies your resulution.

Thanks
Amit Dutta
 
Share this answer
 
Comments
bhagirathimfs 15-Jun-12 3:08am    
<table style="width:100%">
<tr>
<td style="width:60px">
<asp:Button ID="Button1" runat="server" Width="60px" Text="Button" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text="Label">
</td>
<td>
<asp:TextBox ID="TextBox1" runat="server">
</td>
</tr>
</table>

I have done this ,but it is not working
AmitDutta_Bokaro 15-Jun-12 3:24am    
this code is working absolutely fine as per your requirements,
do one thing: restart the iis, restart the process, delete all tem and cookie and run the page. sometimes we do get undesired data because of cache.
sagar wasule 15-Jun-12 3:30am    
Actually this was the example given by me , bhagirathimfs has not shared code uptill now
bhagirathimfs 15-Jun-12 5:39am    
i have posted my code please go through it
bhagirathimfs 15-Jun-12 6:03am    
Thanks for helping Solved the problem
please post the code here
for quick ans.
 
Share this answer
 
Comments
bhagirathimfs 15-Jun-12 2:57am    
which code you need?
Sandeep Mewara 15-Jun-12 3:04am    
This is not an answer. Please use 'Have a Question or Comment' link to respond to an answer. It will notify answerer of your comment such that he can come back and reply.
AmitDutta_Bokaro 15-Jun-12 4:25am    
bhagirathimfs i was asking for the html u was using anyways in this regards u must have got the solution to your problem...
bhagirathimfs 15-Jun-12 5:40am    
i have posted my code please go through it

have got the solution to your problem...
No :(
bhagirathimfs 15-Jun-12 6:03am    
Thanks for helping Solved the problem

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900