-->

Tuesday, March 18, 2014

GridView header row Border style as Double example in asp.net

 Initial Steps for viewers

Step-1 : Open Visual Studio IDE
Step-2 : Add New Webform into your project
Step-3 : Open Design page for adding control onit.
Step-4 : You can change Border style of header as Double by Property window.
GridView header row Border style as Double example in asp.net

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" DataKeyNames="Sno" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="Sno" HeaderText="Sno" InsertVisible="False" 
                ReadOnly="True" SortExpression="Sno" />
            <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
            <asp:BoundField DataField="address" HeaderText="address" 
                SortExpression="address" />
            <asp:BoundField DataField="contactno" HeaderText="contactno" 
                SortExpression="contactno" />
        </Columns>

   <HeaderStyle BorderStyle="Double" />

    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        DeleteCommand="DELETE FROM [userdataTable] WHERE [Sno] = @Sno" 
        InsertCommand="INSERT INTO [userdataTable] ([name], [address], [contactno]) VALUES (@name, @address, @contactno)" 
        SelectCommand="SELECT * FROM [userdataTable]" 
        UpdateCommand="UPDATE [userdataTable] SET [name] = @name, [address] = @address, [contactno] = @contactno WHERE [Sno] = @Sno">
        <DeleteParameters>
            <asp:Parameter Name="Sno" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="contactno" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="contactno" Type="Int32" />
            <asp:Parameter Name="Sno" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <div>
    
    </div>
    </form>
</body>
</html>

Code output:


GridView header row Border style as Double example in asp.net

Sunday, March 16, 2014

Change Header border style of Grid View in ASP.NET

 Initial Steps for viewers

Step-1 : Open Visual Studio IDE
Step-2 : Add New Webform into your project
Step-3 : Open Design page for adding control onit.
Step-4 : You can change Border Style of Header row using property window

Change Header border style of Grid View in ASP.NET

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
        AutoGenerateColumns="False" DataKeyNames="Sno" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="Sno" HeaderText="Sno" InsertVisible="False" 
                ReadOnly="True" SortExpression="Sno" />
            <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
            <asp:BoundField DataField="address" HeaderText="address" 
                SortExpression="address" />
            <asp:BoundField DataField="contactno" HeaderText="contactno" 
                SortExpression="contactno" />
        </Columns>

 <HeaderStyle BorderStyle="Groove" />

    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        DeleteCommand="DELETE FROM [userdataTable] WHERE [Sno] = @Sno" 
        InsertCommand="INSERT INTO [userdataTable] ([name], [address], [contactno]) VALUES (@name, @address, @contactno)" 
        SelectCommand="SELECT * FROM [userdataTable]" 
        UpdateCommand="UPDATE [userdataTable] SET [name] = @name, [address] = @address, [contactno] = @contactno WHERE [Sno] = @Sno">
        <DeleteParameters>
            <asp:Parameter Name="Sno" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="contactno" Type="Int32" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="contactno" Type="Int32" />
            <asp:Parameter Name="Sno" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <div>
    
    </div>
    </form>
</body>
</html>

Code output:

Output of  Header border style of Grid View

Searching for Data Structure in C Programming

Searching 

Searching is an operation that is applied on any of the data structure looking for the existence of an item or element within the same. So searching is simply a Boolean operation that returns TRUE if the element looking for exists in the data structure, otherwise to return FALSE. In almost every area of computing field searching is found. So understanding and implementation of searching is must for a computer programmer along with learning of data structure. Following are the few examples of searching:
. Searching a file in a directory or folder
. Searching name in a list of names
. Searching an address of a web site
. Searching a free partition to allocate memory to process
. Searching a free space in disk to allocate for a file
Basically searching operation is applied to every data structure to find out the existence of a member or element within it. The type of searching used for implementation depends on:
. Direct availability of index or address of elements
. Order of elements that are stored in data structure
We study here different types of searching like linear search and binary search applied on linear data structure, lists (array and linked list).

Double Ended Queue (DEQUE) in 'C'

Double Ended Queue (DEQUE)

DEQUE (pronounced as deck), Double Ended Queue, is a type of Queue in which additions and deletion are deletions are done from both the ends. So it is called as Double Ended Queue.

DEQUEs are of two types.

1. Input restricted DEQUE:
                        In this type of Double Ended Queue, the ADD (insertion) Operation is restricted to one end and the DELETE operation is done from both the ends. Only REAR is used for insertion operation and both FORNT and REAR are used for deletion operation. When an item is added REAR is updated accordingly and the item is inserted at REAR index. When an item is deleted from the FRONT end, FRONT is updated accordingly FRONT<--FRONT+1. When an item is deleted from REAR end, REAR is updated as REAR<--REAR-1.

2. Output restricted DEQUE:
                        It is opposite of Input restricted DEQUE. In this type Double Ended Queue, the DELETE operation is restricted to one end the insertion (ADD) operation is done to both the ends. Only FRONT is used for DELETE operation and both FRONT and REAR are used for ADD operation. When an item is added to the FRONT end, FRONT is updated accordingly FRONT<--FRONT-1, and the item is inserted at FRONT index. When an item is added to the item is inserted at REAR Index.

Saturday, March 15, 2014

How to access cell value from DataTable in ASP.NET

Introduction

Suppose, i have Database table with some rows and columns. Look like given below

How to access cell value from DataTable in ASP.NET

And i want to access cell value of it. Now, first discuss about DataTable, It is container, It Contains multiple Data Columns and multiple Data Rows. It is Main part of ADO.NET library. In this program, we will retrieve cell value of DataTable. Now, first load DataTable with any datasource using load( ) method. After that you can retrieve cell value of it easily.

Now Let's go for an example

Above mentioned snapshot, If we want to access jacob text from given table then consider this table as 2D array. Now, you can access this text from table using itemArray property of DataRow class. Like

string name =  instance of DataTable.Rows[0].ItemArray[1].ToString();
 Similarly, if want to access whole data of single column then must use loop, such as

for (int i = 0; i < table .Rows .Count; i++)
                {
                    
            string  name1 =   instance of DataTable.Rows[i].ItemArray[1].ToString(); +"<br/>";  
                    
                   
                }

Output of given mentioned code

How to access cell value from DataTable in ASP.NET


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Configuration;
using System.Data;

public partial class Default5 : System.Web.UI.Page
{
    string name1=string.Empty ;
    protected void Page_Load(object sender, EventArgs e)
    {
        using (SqlConnection con = new SqlConnection())
        {
            con.ConnectionString =ConfigurationManager.ConnectionStrings ["ConnectionString"].ToString ();
            con.Open ();
            using(SqlCommand cmd = new SqlCommand ())
{
                cmd.CommandText = "select * from Register";
                cmd.Connection =con;
                SqlDataReader rd=cmd.ExecuteReader ();
                DataTable table;
                table = new DataTable();
                table.Load(rd);
                for (int i = 0; i < table .Rows .Count; i++)
                {
                    
              name1 +=  table.Rows[i].ItemArray[1].ToString() +"<br/>";  
                    
                   
                }
                Label1.Text = name1;
}
        }

    }

    }

C function for an ADD operation

C function for an ADD operation:


void addlq(QUEUE *front, QUEUE *rear, int item)
{
QUEUE *temp = (QUEUE*) malloc (sizeof(QUEUE));
temp-->i=item;
temp-->link=0;
if (rear= =0)
{ rear=temp; front=temp; }
else
{ rear-->link=temp; rear=temp; }
}

To implement a Linear Queue using Linked List, in C, a self-referential struct QUEUE can be used similar to Linked List implemented STACK. The user define data type struct QUEUE contain one field to store the data say int i and the other field QUEUE *link to store the address of next node.
struct QUEUE
{
int i;
QUEUE *link;
};


Implementation of Circular Queue using 1-d array

Implementation of Circular Queue using 1-d array: 

  The Circular QUEUE can be represented graphically as consecutive blocks when it is implemented using one-dimensional circular array. N the maximum number of elements can be added into the QUEUE is called as size of QUEUE. To represent a QUEUE an array of size N can be used:

 In the above representation the size of QUEUE is 8. FORNT and REAR index variables can be used to do the DELETE and ADD operations respectively. Initially when the QUEUE is empty FORNT and REAR are assigned with a value 0, because of Lower Bound 1 of the array. When both are equal to 0, then the 
QUEUE is said to be empty.
              When first element is added into QUEUE, REAR and FRONT are both incremented by 1 and the element to be added is placed at REAR index of QUEUE, QUEUE is the name of the array i.e. FORNT<--1, REAR<--1 and QUEUE [REAR]<--ITEM. ITEM is the element to be added to QUEUE. In the further addition operations, the REAR is incremented by 1 and the ITEM is copied at REAR index. When the REAR=N, then REAR is set equal to 1 and addition is done at REAR index. When the REAR is equal to N and FRONT=1 OR FORNT=REAR+1, QUEUE is    said to be full. If any addition is done when the QUEUE is full, ‘overflow’ occurs.
             When the element is to be deleted from the QUEUE, the element stored in the QUEUE with FRONT index is deleted by copying it in ITEM and the incrementing FRONT by 1. When FRONT=N then FORNT is set equal to 1. When FRONT is equal to 0, the QUEUE is empty. When the QUEUE is empty and if the deletion operation is done ‘underflow’, occurs.
Example: Consider a QUEUE of size 8. It is initially represented as follows:



        In order to implement the Circular QUEUE using one-dimensional array, an array of size N is used with name QUEUE and FRONT and REAR as the indices to represent the deletion end and addition end respectively. Following algorithms are used for the purpose.

© Copyright 2013 Computer Programming | All Right Reserved