ASP.NET
  Home arrow ASP.NET arrow Page 2 - How to Play with DataGrid Control
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP.NET

How to Play with DataGrid Control
By: Mayank Gupta
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 53
    2004-06-16

    Table of Contents:
  • How to Play with DataGrid Control
  • How the Work is Done
  • The Page_Load Event Handler
  • Editing
  • Handling Item Edit Events
  • Handling Multiple Row Selection for Deletion by Checkbox Control
  • Finishing Up

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    How to Play with DataGrid Control - How the Work is Done


    (Page 2 of 7 )

    How the work is actually done:

    <HTML CODE>
    <HTML>
    <HEAD>
    <meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
    <meta content="C#" name="CODE_LANGUAGE">
    <meta content="JavaScript" name="vs_defaultClientScript">
    <meta content="
    http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
    </HEAD>
    <body MS_POSITIONING="GridLayout">
    <FORM Runat="server">
    <TABLE id="Table2" >
    <TR>
    <TD>
    <asp:DataGrid id="dgNonApproveList" runat="server" OnPageIndexChanged="MyDataGrid_Page" OnCancelCommand="dgNonApproveList_CancelCommand" OnUpdateCommand="dgNonApproveList_UpdateCommand" OnEditCommand="dgNonApproveList_EditCommand"  DataKeyField="DocTId" Width="752px" AllowPaging="True" AllowSorting="True" ForeColor="#000000" Font-Names="Arial" Font-Size="Smaller" AutoGenerateColumns="false">
    <HeaderStyle Font-Bold="True"></HeaderStyle>
    <Columns>
    <asp:TemplateColumn>
      <HeaderTemplate>
       <input type="CheckBox" name="SelectAllCheckBox" onclick="SelectAll(this)">
      </HeaderTemplate>
      <ItemTemplate>
       <asp:CheckBox id="SelectCheckBox" Runat="Server" />
      </ItemTemplate>
     </asp:TemplateColumn>
     <asp:BoundColumn DataField="UserId" HeaderText="User Id"></asp:BoundColumn>
     <asp:BoundColumn DataField="DocTitle" HeaderText="DocTitle"></asp:BoundColumn>
     <asp:TemplateColumn>
      <HeaderTemplate>
       Date From
      </HeaderTemplate>
      <ItemTemplate>
       <%# DataBinder.Eval(Container, "DataItem.DateTo")%>
      </ItemTemplate>
      <EditItemTemplate>
    <asp:Calendar ID=calDateFrom SelectedDate='<%# DataBinder.Eval(Container, "DataItem.DateTo")%>' Runat="server" Width="186px" ForeColor="Black" Font-Size="8pt" Height="134px" BackColor="White" DayNameFormat="FirstLetter" Font-Names="Verdana" BorderColor="#999999" CellPadding="4"><TodayDayStyle ForeColor="Black" BackColor="#CCCCCC"></TodayDayStyle><SelectorStyle BackColor="#CCCCCC"> </SelectorStyle><NextPrevStyle VerticalAlign="Bottom"></NextPrevStyle>
       <DayHeaderStyle Font-Size="7pt" Font-Bold="True" BackColor="#CCCCCC"></DayHeaderStyle>
    <SelectedDayStyle Font-Bold="True" ForeColor="White" BackColor="#666666"> </SelectedDayStyle><TitleStyle Font-Bold="True" BorderColor="Black" BackColor="#999999"> </TitleStyle> <WeekendDayStyle BackColor="#FFFFCC"> </WeekendDayStyle> <OtherMonthDayStyle ForeColor="#808080"> </OtherMonthDayStyle>
       </asp:Calendar>
      </EditItemTemplate>
     </asp:TemplateColumn>
     <asp:TemplateColumn>
      <HeaderTemplate>
    Date Till
      </HeaderTemplate>
      <ItemTemplate>
       <%# DataBinder.Eval(Container, "DataItem.DateTill")%>
      </ItemTemplate>
      <EditItemTemplate>
    <asp:Calendar ID="calDateTo" SelectedDate='<%# DataBinder.Eval(Container, "DataItem.DateTill")%>' Runat="server" Width="186px" ForeColor="Black" Font-Size="8pt" Height="134px" BackColor="White" DayNameFormat="FirstLetter" Font-Names="Verdana" BorderColor="#999999" CellPadding="4"> <TodayDayStyle ForeColor="Black" BackColor="#CCCCCC"></TodayDayStyle> <SelectorStyle BackColor="#CCCCCC"> </SelectorStyle> <NextPrevStyle VerticalAlign="Bottom"></NextPrevStyle>
       <DayHeaderStyle Font-Size="7pt" Font-Bold="True" BackColor="#CCCCCC"></DayHeaderStyle>
    <SelectedDayStyle Font-Bold="True" ForeColor="White" BackColor="#666666"> </SelectedDayStyle> <TitleStyle Font-Bold="True" BorderColor="Black" BackColor="#999999"> </TitleStyle> <WeekendDayStyle BackColor="#FFFFCC"></WeekendDayStyle><OtherMonthDayStyle ForeColor="#808080"> </OtherMonthDayStyle></asp:Calendar>
      </EditItemTemplate>
     </asp:TemplateColumn>
    <asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update!" CancelText="Cancel!" EditText="Edit!"></asp:EditCommandColumn>
    </Columns>
    </asp:datagrid>
    </TD>
    </TR>
    <TR>
    <TD align="left"><asp:button id="btnApprove" onclick="btnApprove_Click" runat="server" Text="Delete"></asp:button><asp:label ID="MessageLabel" ForeColor="Red" EnableViewState="False" Runat="Server" Font-Bold="True"></asp:label></TD>
    </TR>
     </TABLE>
    <TABLE id="Table1" style="Z-INDEX: 102; LEFT: 8px; WIDTH: 760px; POSITION: absolute; TOP: 8px; HEIGHT: 77px" cellSpacing="1" cellPadding="1" width="760" border="0">
     <TR>
      <TD style="WIDTH: 114px">Record Per Page</TD>
    <TD style="WIDTH: 186px"><asp:textbox id="txtPageLength" runat="server" Width="64px"></asp:textbox></TD>
     </TR>
     <TR>
      <TD style="WIDTH: 114px">Paging Style</TD>
    <TD style="WIDTH: 186px"><asp:radiobutton id="optNum" runat="server" Text="1 2 3 4 ...." GroupName="opt" Checked="True"></asp:radiobutton><asp:radiobutton id="button" runat="server" Text="Pre Next" GroupName="opt"></asp:radiobutton></TD>
    <TD><asp:button id="btnDisplay" onclick="btnDisplay_Click" runat="server" Text="Display Record"></asp:button></TD>
     </TR>
     <TR>
      <TD style="WIDTH: 114px">Sort By</TD>
      <TD style="WIDTH: 186px">
    <asp:dropdownlist id="ddwnSortBy" runat="server">
      <asp:ListItem Value="DocTemplate.DocTitle">Document Title</asp:ListItem>
      <asp:ListItem Value="UserDocDefault.DateTo">Date From</asp:ListItem>
      <asp:ListItem Value="UserDocDefault.DateTill">Date Till</asp:ListItem>
      </asp:dropdownlist></TD>
     </TR>
     </TABLE>
    </FORM>
    </body>
    </HTML>

    More ASP.NET Articles
    More By Mayank Gupta


     

    ASP.NET ARTICLES

    - Developing a Mini ASP.NET AJAX Server Centri...
    - Disadvantages of the ASP.NET MVC Framework
    - Advantages of the ASP.NET MVC Approach
    - ASP.NET Web Forms Weaknesses
    - ASP.NET Web Forms Meets ASP.NET MVC
    - Source Code for Saving and Retrieving Data w...
    - Using GridView to Save and Retrieve Data wit...
    - Handling Dynamic Images in ASP.NET 3.5 AJAX ...
    - Retrieving Data with AJAX and the GridView C...
    - Playing with Images in ASP.NET 3.5 AJAX Appl...
    - Saving and Retrieving Data with AJAX
    - Enhancing PHP Via the ASP.NET AJAX Framework...
    - Enhancing PHP Programming with the ASP.NET A...
    - Classes and ASP.NET AJAX
    - Using ASP.NET AJAX

     
    Best Practices for Windows Vista Migration Presentation
    Dell and Microsoft recently held a series of face-to-face seminars entitled, &qu....

     
    Creating a Culture for Code Reuse
    If you oversee development teams you know that like it or not proprietary and ex....

     
    Keys to Web Application Acceleration: Advances in Delivery Systems
    Accelerate Web apps by up to 5x. Ensure significantly faster access to the Web a....

     
    Optimizing Application Monitoring
    Tired of finding out from your customers that you're offline? This white paper e....

     
    Solaris to Solaris Migration -- Migrating applications from Sun SPARC to Dell PowerEdge R900
    This comprehensive Migration Guide reviews the approach that Principled Technolo....

     




    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT