Category Archives: ListView

ListView

[RESOLVED]How to disable 2nd click on litsview item

Hi All,

I have listview which contains product catagories. Once the itme is clicked in that listview, I want to disable the click. I am using a linkbutton inside the listview. Have researched on web regarding the same, but no solution yet.

Please guide on this.

What do you mean by 2nd click, do you want to disable click on selected item or other items

syed amjad

What do you mean by 2nd click, do you want to disable click on selected item or other items

Yes. Once the item is selected , i want to disable the click

Hi,

So you want to disable the linkbutton after the first click:

Maybe you can call the postback directly in the onclick, something like:

LinkButton1.Attributes.Add("onclick", "this.disabled=true;" + Page.ClientScript.GetPostBackEventReference(LinkButton1, "").ToString());

Hope it can help you.

Best Regards,
Amy Peng

[RESOLVED]how to perform jquery function on lstbox selectionchange

Hi

how i can perform jquery function from lstbox selection index change ???, its in dialog box so unable to call server side selctionchange method. so need to use jquery ajax.

Thanks

can you give some detail related to what jquery function are you trying to implement in listview ? and some code sample 

newbiefreak

can you give some detail related to what jquery function are you trying to implement in listview ? and some code sample 

actually i want to place two listbox in jquery dialog using a jquery update panel ,1st listbox values are filled in page load , but i want to fill the values of 2nd listbox using jqery udate panel respected to 1st listbox value.

it short i want to show subcategoryies in 2nd listbox respected to cateogry listbox in 1st listbox.

how i can do using jqery update panel. 

Hi,

You can check the following posts-

http://www.delicious.com/anupdg/cascading

[RESOLVED]show/ hide columns in a ListView

Hi 

here is my Listview markup:

<asp:ListView ID="lstProducts" runat="server" DataSource='<%# GetList() %>'>
        <LayoutTemplate>
            <table id="tblProducts" runat="server" style="border:solid;border-width:thin">
            <thead>
                <tr>
                    <td>Item
                    </td>
                    <td>Avail
                    </td>
                    <td>Qty
                    </td>
                </tr>
            </thead>
            <tbody>
                <tr id="ItemPlaceholder" runat="server">
                </tr>
            </tbody>
        </table>
    </LayoutTemplate>
    <EmptyDataTemplate>
        <table id="tblProducts" runat="server" style="border:solid;border-width:thin">
            <thead>
                <tr>
                    <td>Item
                    </td>
                    <td >Avail
                    </td>
                    <td>Qty
                    </td>
                </tr>
            </thead>
        </table>
    </EmptyDataTemplate>
    <ItemTemplate>
        <tr>
            <td id="tdITMREF" style="text-align: left">
                <asp:Label ID="lblITMREF" runat="server" Text='<%#Eval("ITMREF") %>'></asp:Label>
            </td>
            <td>
                <asp:Label ID="lblAvail" runat="server" Text='<%#Eval("AVAIL") %>'></asp:Label></td>
            <td>
                <input name="txt<%#Eval("ITMREF") %>" />
            </td>
        </tr>
    </ItemTemplate>
</asp:ListView>

I wanted to know if there is a way to show/hide specific <TD> (column) according to a parameter (can be querystring or another server side parameter i.e from DB)?

if not is there any other data bound control that is not gridview to do it.

gridview is very heavy for my needs.

thanks

Barak

Add "runat=server" in your td that you want to show/hide from code behind and use following:

lstProducts.FindControl("id of your td");

or

lstProducts.Rows.FindControl("id of your td");

Hi,

you can use below methods to hide your column in list view

public partial class Form1 : Form {
public Form1() {
InitializeComponent();
listView1.Columns[1].Width = 0;
listView1.ColumnWidthChanging += listView1_ColumnWidthChanging;
}

private void listView1_ColumnWidthChanging(object sender, ColumnWidthChangingEventArgs e) {
if (e.ColumnIndex == 1) {
e.NewWidth = 0;
e.Cancel = true;
}
}
}

or you can refer below article for the same i.e removing the column dynamically from list view

http://social.msdn.microsoft.com/Forums/en-US/b50a404a-ae4c-4cb2-92a0-db159aeba767/how-does-one-hide-a-listview-column

thanks

that helps.

[RESOLVED]How can i display multiple data from database?

hi, 

Suppose theres a query -> "Select * from TableName where employeesalary< 10000 and employeesalary > 5000";

problem: if there is only one data then we can write :-> TextBox/Label1.Text=dbreader["EmpName"].ToString();

 TextBox/Label1.Text=dbreader["EmpAddress"].ToString();

 TextBox/Label1.Text=dbreader["EmpEmail"].ToString();  etc.

But displays particular only one employee record for display multiple between 5000 & 10000?

 

better in gridview 

Hi JJBhatt,

For displaying multiple (collection or list based) data items, those template data bound control (like GridView, DataList, Repeater) can help on this. You just need to supply the data source collection to the control’s DataSource property and call "DataBind"
method.

#Comparing ListView with GridView,DataList and Repeater
http://weblogs.asp.net/anasghanem/archive/2008/09/06/comparing-listview-with-gridview-datalist-and-repeater.aspx

and for more information about ASP.NET data binding, you can take a look at the following KB article:

#ASP.NET data binding overview
http://support.microsoft.com/kb/307860

[RESOLVED]How to create listview dynamically using jquery mobile?

I am using jquerymobile in my application.I had to create a listview in it bt the items should be dynamically created ..can any one please help with a sample code.??statically i had created a list as below

<ul data-role="listview" data-inset="true" >
<li><a href="choose_town.html" data-transition="slidedown"> <img src="Themes/images/sushis.jpg"/> <h3> Continental</h3></a></li>
<li><a href="choose_town.html" data-transition="slidedown"> <img src="Themes/images/pizza.jpg"/> <h3> Italian</h3></a></li>
<li><a href="choose_town.html" data-transition="slidedown"> <img src="Themes/images/kebap.jpg"/> <h3>Mexician</h3></a></li>
<li><a href="choose_town.html" data-transition="slidedown"> <img src="Themes/images/burger.jpg"/> <h3> American</h3></a></li>
<li><a href="choose_town.html" data-transition="slidedown"> <img src="Themes/images/nems.jpg"/> <h3> chinese</h3></a></li>
<li><a href="choose_town.html" data-transition="slidedown"> <img src="Themes/images/tradi.jpg"/> <h3> Something more traditional</h3></a></li>

</ul>

I need to create the list during the database call..

Hello

You may try use a for loop to create a piece of html string that represents a DOM node, then concatenate these strings, and finally output it.

hi

Thanks for your reply..I am trying to do that…

Design View Changes Don't Alter Source Code

 I had this problem several times. I made a change to a control usually a data control like a gridview, detailsview, and right now a listview. When I finish making the changes in design view I notice that the tab does not have the * indicating a change and
when I go to source mode none of my changes have been reflected in the code. Why is this?

This may happen if you try to change anything while your application is running in debug mode. Please check if that’s not the case.

Hope it helps.

[RESOLVED]How to find the child controls in debug mode in watch window?

Hi there,

I want to see the child controls in the ListView Controls in debung mode in the Item_Command event.

When the event occured I want to trace into the code and check the children of e.item.controls.

How can I do this?

[RESOLVED]CONFUSED WITH POSITION RELATIVE

I’m trying to use <div>s more on my asp.net pages for layout but my divs with position:relative don’t seem to work the way the MSDN web page describes positioning.  So rather than try to discuss position:relative, I would like to explain what I would like
to do and see if there is a reasonable way to do it.

I would like to enclose the various components of my page, including FormViews, GridViews, and ListViews in <div>s and use style="position:relative(?) to add spaces between <div>s.   The article seems to say that I can use relative positions to add space
between the divs as shown below.

 

<div id="divTop" style="position:relative; left:0px; top:0px;">

<div id = "div1" style-"position:relative; left:0px; top:10px" >

   Ths div should start 10px down from the top of divTop.

</div>

<div id = "div2"  style-"position:relative; left:0px; top:10px" >

   This div should start 10px down from the bottom of div1.

</div>

<div>

This doesn’t seem to space the divs as I would like.  Spacing down from the previous div would allow subsequent divs to float down if new content is added in a div.  Now I have to manually change the tops.  I can I get this to work.

 

Thanks

 

 

 

DeepPowder

This doesn’t seem to space the divs as I would like.

Have you tried different values for the ‘top’ property?

An alternative would be to use the ‘margin-top’ property, to add spacing between the element and the previous element, but the position:relative should work.  Also, what browser are you using?

yes i have tried different top values. On actual asp.net pages I would have to enter something like top:120 to get a spacing of about 20px.  I’m using IE.8

Thanks.

 

DeepPowder

something like top:120 to get a spacing of about 20px

You have to include the unit, as well as the value.  For example:

top: 120px;

or

top: 120em;

or

top: 120%;

I do believe that the uom (px) is included in all divs in my example above and in my live website.

Any other thoughts?

 

DeepPowder

I do believe that the uom (px) is included in all divs in my example above and in my live website.

But not in the line that I quoted, in my last post.

Also, the example that you provided, in your OP, isn’t valid HTML, which means that I have no idea whether the information you’re giving is accurate or correct.

If the HTML that you provided is exactly what you’ve got in your website, then correct the errors and it should work.

DeepPowder

Any other thoughts?

Try this:

<div id="divTop" style="background-color: black;padding-top: 10px;">
    <div id="div1" style="background-color: #ccc;">
        Ths div should start 10px down from the top of divTop.
    </div>
    <div id="div2" style="position: relative; top: 10px; background-color: #666;">
        This div should start 10px down from the bottom of div1.
    </div>
</div>

Hi,

You can use margin and padding for this purpose. Share us what is the desired layout you want. May be show us as an image.

asteranup

You can use margin and padding for this purpose.

As I’ve demonstrated.

asteranup

Share us what is the desired layout you want.

Read the original post.

Thanks for all your help and suggestions.  But my question is how does relative positioning work.  Per W3Schools

"The element is positioned relative to its normal position, so "left:20"      adds 20 pixels to the element’s LEFT position"

I have created a simple test web page with an outer div and two inner divs.  Each has position:relative; left:10px; top:20px;  THis is pretty much what my example showed.

According to the above, the second inner div should be positioned 20 px down from the end of the first div.  Without relative positioning, it would be displayed immediately after the first inner div.  However it doesn’t.  I appears that all relative positioning
is from the containing control, not from its position without the relative position. 

I know there are lots of work arounds but I wanted to know if relative position doesn’t work as advertised or if it works in another way. 

could someone put me out of my misery.  If you get relative positioning to work as described, please send me your HTML so I can see what I’m doing wrong.

Thanks

 

DeepPowder

According to the above, the second inner div should be positioned 20 px down from the end of the first div. 

No; both divs are within a containing div, the position on those two divs are going to be
relative to the containing div only. The second div isn’t going to take a mind of it’s own and move itself another 20px down after the first div has positioned itself. It will only be 20px down from the containing div.

A simple test you can do to prove top: 20px; is working on the divs once position is set is to float them side by side and play around with the top propertys.

<style type="text/css">
        #Container{
        width: 1000px;
        height: 500px;
        background: red;
        }
    
        #Div1{
        width: 300px;
        height: 300px;
        position: relative;
        float: left;
        left: 10px;
        top: 20px;
        background: blue;
        }
    
        #Div2{
        width: 300px;
        height: 300px;
        position: relative;
        left: 10px;
        top: 20px;
        float: left;
        background: green;
        }
    </style>

    <div id="Container">
        <div id="Div1"></div>

        <div id="Div2"></div>
    </div>

Colly thanks,

After I posted my reply this morning I did some more testing and realized that the positioning was from the container not the control before. So thanks. 

To use <div>s effectively for positioning controls on a page, I would like <div2> to float behind <div1>.  For example if <div1> contained a gridview which depending on the filter would be taller or shorter.  I would like <div2> to float down maybe 20 px
below <div1>. 

It looks like you cannot do that with positioning.  For a single column page, the best solution I can think of is <br/>s to space.  Is there a better way?

You would simply add margin-top: 20px; to Div 2.

DeepPowder

After I posted my reply this morning I did some more testing and realized that the positioning was from the container not the control before.

That isn’t entirely true.  If, in your initial example, you remove the position:relative from div1 then div2 will be separated from div1 by 10 pixels.  Ultimately, it’s down to the browser’s interpretation of the rules (that’s why we have problems when rendering
in IE).

Hi, you can remove the attribute “float: left;”, and then set “top” attribute value of the second div 20px bigger than the first div.

[RESOLVED]load data into list view

hello friends,

i am ussing list view for display content from database. i have one coloumn named description but as per designing point of view i need to take only 845 char from that description.

plz help me to fix no of char in list view:

below is  my script code:

<asp:ListView runat="server" ID="ListViewAllReport" GroupItemCount="2" EnableTheming="False">
        <LayoutTemplate>
            <asp:PlaceHolder runat="server" ID="groupPlaceHolder" />
        </LayoutTemplate>
        <GroupTemplate>
            <asp:PlaceHolder runat="server" ID="itemPlaceHolder" />
        </GroupTemplate>
        <ItemTemplate>
            
                              <div class="multiColBoxWrapTwoCol"><div class="multiColBox">
                           
                             <asp:HyperLink ID="HyperLink2" runat="server" NavigateUrl='<%# FormatUrl((String) Eval("Model_Variant")) %>'>
                             </asp:HyperLink>
                            <h2>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Product_Name") %>'></asp:Label>
                            </h2>
                     <%-- <asp:TextBox ID="textbox1" runat="server" Text='<%# Eval("Product_Description") %>'  TextMode="MultiLine" MaxLength="845"></asp:TextBox>--%>
                   <asp:Label ID="lblServices" runat="server" Text='<%# Eval("Product_Name") %>'></asp:Label>
                     
                      <ul class="reportBottom">
            <li>
              <span class="topReportHead">Page</span>
              <span class="topReportContent">10 to 12</span>
            </li>
            <li>
            <span class="topReportHead">Sample</span>
           <span class="topReportContent"> <asp:HyperLink ID="HyperLink3" runat="server" CssClass="sampleLink" NavigateUrl='<%# FormatUrlSample((string)Eval("Model_Variant"),"Hindi") %>'
                                Target="_blank">Hindi</asp:HyperLink>
                            &nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;<asp:HyperLink ID="HyperLink4" runat="server"
                               CssClass="sampleLink" Target="_blank" NavigateUrl='<%# FormatUrlSample((string)Eval("Model_Variant"),"English") %>'>English</asp:HyperLink>
              
              </span>
            </li>
            <li>
              <span class="topReportHead"><span class="WebRupee">RS</span><strong><asp:Label ID="lblCharges" runat="server"
                                Text='<%# Eval("Product_Price") %>'></asp:Label></strong>&nbsp;|&nbsp; USD&nbsp;-&nbsp;
                                 <strong><asp:Label ID="Label4" runat="server" Text='<%# Eval("rate_dollar") %>'></asp:Label></strong></span>
              
                <span class="topReportContent">
                       <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# FormatUrl((string)Eval("Model_Variant")) %>' CssClass="btCommon">Order Now</asp:HyperLink></span>
            </li>
          </ul>
                            
                      
                      
                             </div>
                            </div>
                            
        </ItemTemplate>
        <EmptyDataTemplate>
        </EmptyDataTemplate>
    </asp:ListView>

Before saving of data  to database only restrict the description  values with 845 characters by using the Maxlenth value of  input textbox is the one way

Second one way  you can restrict the datatype value of like varchar(850) in database columns chracters lenth .

no i dont want to restrict fill value in database.

is that any way from code side to fix the length of string.

Hi atul do like this

<%#Eval("YourColumnName").ToString().Length>845?Eval("YourColumnName").ToString().Substring(0,845):Eval("YourColumnName") %>

Hello anuj,

i did like this i tried as u said but getting out of index error

 fixDesc = desc.Substring(0, Math.Min(desc.Length, 845)).ToString();

You have to use my whole code as it firsts checks wether data is greater than 845 or not. If yes then it will substirngs data.

Show me your code where you want to implement I’ll provide more help.

[RESOLVED]How to find the components inside listview in runtime?

Hi there.

I want to access a control inside the Item_command event of list view.

I’m using this line of code:

CTYPE(e.item.findcontrol("ddlCities"),dropdownlist).something

an error is rising in this line that says "object instance reference"

How can I see the list of controls inside listView in watch windows in debug mode?

can you try e.Item.Controls ?

Ofcourse I’ve tried that.

But I can  just see the control count:

e.item.controls.count

Or control type:

e.item.controls(0)
e.item.controls(1)
e.item.controls(2)
e.item.controls(3)

Is there any way to see the name of all controls somewere?

I think you can use e.Item.Controls[0].GetType() or if you want to see detailed view of your control, use below:

e.Item.Controls._controls[0]

You can directly type this in watch window or otherwise you can see for "Non-Public Members" after writing e.Item.Controls and then see list of controls in _controls list.

Hope this helps!

try like

e.item.controls(0).name

or you will have to parse the control like

textbox txt = e.item.controls(0) as textbox
txt.id
you can get the type using
e.item.controls(0).GetType()