.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Datalist, Gridview or Listview

Posted By:      Posted Date: September 07, 2010    Points: 0   Category :ASP.Net
I am extremely new to ASP and just started learning. I want to know which is better between Datalist, Gridview or Listview if I need paging and sorting functionality? This is what I have so far.I've tried Datalist but I am having trouble with the paging portion. I've tried gridview and listview and got the paging to work but for some reason, when I click on Pg 2, it refreshes the search or something and what was shown on Pg 1 would appear again on Pg 2.Thanks in advance for your help.<asp:MultiView id="MultiView1" ActiveViewIndex="0" Runat="server">                        <asp:View ID="View1" runat="server">                        <asp:DataList ID="DataList1" runat="server" DataKeyField="ItemID"                         DataSourceID="SqlDataSourceImage1" Width="100%"                         HorizontalAlign=

View Complete Post

More Related Resource Links

Manually coding controls such as gridview, listview, repeater, etc.


using vs2010 and .net 4

In my project I have a separate DAL built from class files that I'd like to use to store my code for CRUD operations against my database.

I'm having a hard time finding examples of how to code server controls like the gridview, listview, repeater etc., for CRUD operations manually, i.e., without a datasource control of some flavor.

I don't have any problem manually coding the referenced controls to get my data, but I do have problems when it comes to coding them to perform CRUD operations unless I use a datasource control. When I use the datasource controls CRUD operations seem to automagically appear out of nowhere after they're configured.

Can someone point me to some samples somewhere? Have I missed a section at MSDN?


from datalist to gridview


hi guys


I have a problem, I wanna Insert that cridentials with gridview but I can't , I could that with datalist , so how can I do this with grid view

if there is a sample code i be happy

thanks to everybody..





Sub InsertAllBasketItems()

Dim productAPI As New basketTableAdapters.OrdersTableAdapter

For Each Item As DataListItem In DataList1.Items

Editmode on GridView inside of ListView

I have a listview and inside the listview I have a gridview.  I'm binding data to the listview, then on the listview itemdatabound I'm binding the gridview. I want to make the gridview editable so I have an edit template and an edit command button.  I have the event rowediting and inside there I set the edit index. Now normally I rebind the control and everything works.  But if I rebind this gridview, nothing happens. I can trace through the rowediting and everything is working.  It's setting the edit index, it goes through the databind and gets the right data and binds it to the control. What is happening?  Why isn't my rebound edit mode gridview showing up?

disable autopostback of checkbox inside of GridView during SelectedIndexChanged of ListView

Hi, I hope my question is clear: I have a checkbox placed inside a gridview: <GridView><asp:TemplateField HeaderText="Driver">   <ItemTemplate>       <asp:CheckBox ID="CheckBoxDriver" AutoPostBack="true" OnCheckedChanged="GridView_Persons_SelectedIndexChanged" ValidationGroup='<%# Eval("ID") + "-" +((GridViewRow)Container).RowIndex %>' CssClass="CXDriver" runat="server" Checked='false' />   </ItemTemplate>       </GridView> For example: A listViewItem 1 has 3 drivers are checked, A listViewItem 2 has 2 drivers are checked. Therefore, if changing the selectedIndex of the list, the checkbox indexChanged event will be fired. How could I disable the autopostback of the checkbox during the listview item changed. Thanks in advance

Display the item in the ComboBox inside the ListView(GridView)

I have the below code used in binding the values to the ComboBox in GridView(ListView), please help me < ListView Margin="480,51,6,14" Name="grid1" ItemsSource="{Binding UserDetail}" IsSynchronizedWithCurrentItem="True" Width="389" Grid.Column="1" > <ListView.View> <GridView> <GridViewColumn Header="UserName" Width="120" DisplayMemberBinding="{Binding Path=WindowsUser}"/> <GridViewColumn Header="Role" Width="140"> <GridViewColumn.CellTemplate> <DataTemplate> <ComboBox Name="Rolecombo" Width="120" ItemsSource="{Binding Path=UserDetail}" SelectedValue="{Binding PFR_Tbl_Role.Role}"/> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> <GridViewColumn Header="Active" x:Name="column" Width="100"> <GridViewColumn.CellTemplate> <DataTemplate> <Grid Width="{Binding ElementName=column,Path=Width}"> <CheckBox IsChecked="{Binding Active}" HorizontalAlignment="Center" /> </Grid> </DataTemplate> </GridViewColumn.CellTemplate> </GridViewColumn> </GridView>  </ListView.View> </ListView>

Passing Querystring Value into Gridview/Listview

I have a master-detail page consisting of a databound GridView and ListView. It's pretty standard - when you select a row in the GridView is shows up the ListView. The problem I'm running into is when I want to link to that page with a specific row pre-selected in both views. It seems like it should be easy enough, but I just can't figure it out. Currently, the ListView is connected to the GridView with a ControlParameter in the SelectCommand. Any assistance would be greatly appreciated. (Let me know if you need more info.)

Is it possible to assign a tooltip to the rows of a GridView in a ListView?

On my VS 2010 WPF app, I've got a GridView within a ListView.  The user searches for some clients, and the clients that match the search are put into the list view.  I'm wondering if it is possible to bring up data that would be specific the the client that the user is hovering the mouse over, in a tooltip?  And if the answer is yes, how is that done?Rod

Help:JAVASCRIPT (checkAll) & (Hide/Unhide GridView1) in a Datalist with a nested Gridview


Hey guys,

 I'm at my wits end on this one looked/Searched/Played/Experimented and I need your help if you can.

This page is going to be primarily used on a mobile device using Win Mobile 5


Need to Accomplish:

  1. Prevent Postback(serverside) of Page using JavaScript (Postback's slow down the page on mobile device)


JavaScript Requests:

  1. Hide and UnHide the Nested Gridview1 by Clicking on a imagebutton1 in DataList1icon_minized_collapse.pngicon_expand_collapse.png
  2. CheckBox in DataList1 Checks All and UNChecks All, CheckBox in just the related Gridview1


Controls :

  1. Gridview1 nested inside DataList1


Note: Datalist1 and Gridview1 have datasource's in production. The Codebehind page is just appling test data to help me figure this out.


Thank you all in advance for helping me with this.

Example data below:<

NULL value of Gridview inside Datalist


I am using a gridview, which is inside datalist, but whenever I try to serach gridview in datalist it reyurns NULL. I using the following code, bolded line is not able to assign gridview:

amespace DataListXML
    public partial class _Default : System.Web.UI.Page
        DataSet _dataSet;
        protected void Page_Load(object sender, EventArgs e)

Gridview within a Listview


Please, I need some help.


I am trying to use a Gridview (pirces) within a Listview (products) and have it working for read only. In the Listview_OnItemDataBound I load the data manually with the statements:

GridViewProductPrices.DataSource = GetDataSourcePrices();


This works fine, but when I press the edit button, the row does not get to editmode.

The problem I have why the edit command does not work is that this statement does not work: this.Rows[rowIndex].RowState = DataControlRowState.Edit;

Findcontrol does not find it either.


If I use a datasourceID in the ASPX then it works:

datasourceid = "SqldatasourcePrices" however I am unable to provide the product key to this datasoure for the Gridview (price).


How can I get the Gridview inside the Listview in edit mode? OR

How can I get the product key to the SqldatasourcePrices

Since the Gridview is inside the Listview, the findcontrol does not find the Gridview control and so I can not set it to edit.

After that is all working, how can I implement the insert?



Here are the details of the ASPX:


<asp:ListView ID="ListView.. ....



Create a GridView\ListView CheckBox coulumn



I'm trying to create a checkbox column in my gridview table via code and i can't make it to work.

below my code where i create all other columns, how can I create a checkBox column?




        private void Get_All_Records_From_DB()

            SqlCommand com = new SqlCommand();
            SqlDataAdapter da = new SqlDataAdapter();

            // com

            com.CommandText = "[Get_Rec]";
            com.CommandType = System.Data.CommandType.StoredProcedure;
            com.Connection = m_mw.GetDbCon().GetConn();
            com.Parameters.Add(new System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data

Listview code syntax help vs Gridview




Any one know how to resolve the below list code? Is there a listview row property or equivalent to gridview?


   For Each rowItem As ListViewrow In Listview1.Rows


repeater, gridview, datalist etc



I'm really confused about this. There are sites which say don't use repeater, use a gridview and some vice versa.

Basically, repeater is the less memory hungry but is read only (and forward only). Fine, all clear.

So, within my C# I am faced with 2 options when populating my repeater/gridview or datalist.

SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;

DataSet ds = new DataSet();
da.Fill(ds, "dsFFC");
grdView.DataSource = ds;



SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd; 

SqlDataReader rdr = cmd.ExecuteReader();
grdView.DataSource = rdr; grdView.DataBind();


Is it this section (above) where the resource is taken up and I need to be careful or within the HTML page, as regardless of the 2 methods above, I can choose either asp:DataList, asp:GridView or asp:Repeater on the HTML page.


Can't style selected item in ListView when GridView is used

Below is a simple window that contains a ListView. Note that it is overriding the SystemColors.HighlightBrushKey to change the color of the selected item.
Works fine, unless  the ListView.View block is enabled, and a GridView is defined.

When that is done, the GridView seems to enforce its own idea of what the selected row should look like.

How can I style the selected row of a ListView using a GridView?

<Window x:Class="WpfApplication1.Window3"
    Title="Window3" Height="300" Width="300">


How to get some data fom GridView (or whatever control DataList etc...)


Hi everyone,

I really love GridView and I like to use it whenever it suits well. Just out of curisority, recently, I been thinking what if i wanna get sme data from the GridView I just bind on the page without actually nesting each column and row? For example :


From the above table, say I wanna take the value Three and Five. How can I get it back from the table ? I know I can query back the database to get the value but that's not what I am trying to figure out here. Thanks all and will be looking forward to getting some cool stuff from you guys.

Listview & GridView , select an item




i create a ListView with a GridView and some GridViewColumn´s in therein:

<ListView ItemsSource="{Binding Records}" x:Name="list" Margin="21,8,21,18.9" Grid.Row="2" Background="{StaticResource linearbrush2}" HorizontalContentAlignment="Center">
      <GridViewColumn  DisplayMemberBinding="{Binding hd_drive}" Width="35" Header=" Drive"/>
      <GridViewColumn  DisplayMemberBinding="{Binding browser_name}" Width="100" Header="Browsername"/>
      <GridViewColumn x:Name="defaultbrowserpath" DisplayMemberBinding="{Binding file_path}" Width="300" Header="Path" /> 

the DisplayMemberBinding-Property points to a ObservableCollection, with the Name Records,

Listview/gridview checkbox is selected or not



I have a question about checkbox in listview or checkbox. How do I know when checkbox is selected or not? Do I have to add Binding or..

Import-Module wpk
Add-Type -AssemblyName presentationframework

[xml] $xaml = @"
  Title="MainWindow" Height="350" Width="525">
    <ListView Grid.Row="0" Grid.Column="1" Grid.RowSpan="3" Margin="3" Name="ListView1" SelectionMode="Extended">
 <GridView AllowsColumnReorder="true">
 <GridViewColumn Header="ServerName">               
      <CheckBox Margin="-4,0,-4,0" IsChecked="False" Name="nupp" Content="{Binding ServerName}"/> 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend