Breaking News
Showing posts with label insert update delete in datagridview in c# how to show data in datagridview in c# datagridview in c# windows application datagridview in c# windows application example codeproject. Show all posts
Showing posts with label insert update delete in datagridview in c# how to show data in datagridview in c# datagridview in c# windows application datagridview in c# windows application example codeproject. Show all posts

Monday, 25 December 2017

How to design Datagridview material in C#|TutorialsTec

In this video i will explain you how to design Data gridview in C# After watchin this tutorial you will be amazed.. You will learn how to change a boring gridview to a stylish Datagridview form

Here the Deo which we will create in our video

How to design Datagridview material in C#|TutorialsTec

Watch the video and Must Subscribe our youtube Channel


Download the Source code from here
http://www.mediafire.com/file/0kbrr5a281b8ip6/Datagrid_view_design.rar



 This article shows you how to get data from GridView and how to store it in the DataTable.Follow these simple steps:Step 1:Drag GridView into the form and define the property of AutoGenerateColumns False.Use the template fields to view GridView data. Design GridView in accordance with your requirements.<asp: GridView runat = "server" ID = "gvShoppingCart" AutoGenerateColumns = "False"
                 
EmptyDataText = "There is nothing in your shopping cart". GridLines = "None"
                 
Width = "31%" CellPadding = "5" ShowFooter = "True" DataKeyNames = "BookId" onrowdeleting = "gvShoppingCart_RowDeleting"
                  
>
                 
<HeaderStyle HorizontalAlign = "Left" BackColor = "# 3D7169" ForeColor = "#FFFFFF" />
                 
<FooterStyle HorizontalAlign = "right" BackColor = "# 6C6B66" ForeColor = "#FFFFFF" />
                 
<AlternatingRowStyle BackColor = "# F8F8F8" />
                 
<Column>
                      
<asp: TemplateField HeaderText = "Iamge Book">
                      
<ItemTemplate>
                          
<asp: Image ID = "BookImg" ImageUrl = '<% # Eval ("BookImage")%>' runat = "server" hight = "15px" width = "20px" />

                      
</ ItemTemplate>
                      
</ asp: TemplateField>

                      
<asp: TemplateField HeaderText = "Book Name">
                         
<ItemTemplate>
                             
<asp: tag ID = "lblBookName" runat = "server" Text = '<% # Eval ("BookName")%>'> </ asp: label> <br />

                         
</ ItemTemplate>
                         
</ asp: TemplateField>

                      
<asp: TemplateField HeaderText = "Price">
                         
<ItemTemplate>
                             
<asp: tag ID = "lblPrice" runat = "server" Text = '<% # Eval ("Bookprice")%>'> </ asp: label> <br />
                         
</ ItemTemplate>

                     
</ asp: TemplateField>

                   
<asp: TemplateField HeaderText = "Quantity">
                  
<ItemTemplate>
                      
<asp: TextBox ID = "TXTQty" run = "server" Text = "1" width = "40px" onkeyup = "Calculate Totals ();"> </ asp: TextBox>
                  
</ ItemTemplate>
                  
<FooterTemplate>
                      
<b> Total Calculation. </ b>
                  
</ FooterTemplate>
              
</ asp: TemplateField>
              
<asp: TemplateField HeaderText = "Total">
                  
<ItemTemplate>
                      
<asp: tag ID = "LBLSubTotal" runat = "server"> </ asp: label></ ItemTemplate>
                  
<FooterTemplate>
                      
<asp: ID tag = "LBLTotal" runat = "server" ForeColor = "White"> </ asp: label>
                  
</ FooterTemplate>
              
</ asp: TemplateField>

                     
<asp: CommandField DeleteText = "Delete" ShowDeleteButton = "True" />
                
                 
</ Column>
             
</ asp: GridView>Open the columns column name on the table.Step 2:Use the following code to retrieve data from GridView and store it in the DataTable.personal getGridInfo empty ()
    
{

        
DataTable dt = new DataTable ();
        
DataRow dr;
        
dt.Columns.Add (New System.Data.DataColumn ("BookName", typeof (String)));
        
dt.Columns.Add (New System.Data.DataColumn ("BookQty", typeof (String)));
        
dt.Columns.Add (New System.Data.DataColumn ("BookImg", typeof (String)));

        
foreach (GridViewRow line gvShoppingCart.Rows)
        
{
            
Image Bookimg = (Image) row.FindControl ("BookImg");
            
Label Booknames = (labels) row.FindControl ("lblBookName");
            
TextBox Bookqty = (TextBox) row.FindControl ("TXTQty");
            
Tag TotalPrice = (labels) row.FindControl ("LBLTotal");
            
dr = dt.NewRow ();
            
dr [0] = Booknames.Text;
            
dr [1] = Bookqty.Text;
            
dr [2] = Bookimg.ImageUrl.ToString ();
            
dt.Rows.Add (dr);
        
}

        
Speech ["QtyTable"] = dt;
        
Response.Redirect ("Admin / Default.aspx");
    
}Step 3:Here, dt.Columns.Add (New System.Data.DataColumn ("BookName", typeof (String))) You can type header text in that column.Call this function where you want to save GridView data in the DataTable.
Read more ...
Designed and Published by.. TANZEEL PRINCE