-->

Thursday, March 20, 2014

How to set outer and inner line of Gridview

How to set outer and inner line of Gridview

<!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>
    <style type="text/css">
        #form1
        {
            width: 162px;
            height: 384px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
<asp:DataList ID="DataList1" runat="server" DataKeyField="Sno" 
        DataSourceID="SqlDataSource1" CellPadding="0" GridLines="Both">
        <ItemTemplate>
            Sno:
            <asp:Label ID="SnoLabel" runat="server" Text='<%# Eval("Sno") %>' />
            <br />
            name:
            <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
            <br />
            address:
            <asp:Label ID="addressLabel" runat="server" Text='<%# Eval("address") %>' />
            <br />
<br />
        </ItemTemplate>
    </asp:DataList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server"
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
        DeleteCommand="DELETE FROM [User] WHERE [Sno] = @Sno"
        InsertCommand="INSERT INTO [User] ([name], [address]) VALUES (@name, @address)"
         SelectCommand="SELECT * FROM [User]"
        UpdateCommand="UPDATE [User] SET [name] = @name, [address] = @address WHERE [Sno] = @Sno">
        <DeleteParameters>
            <asp:Parameter Name="Sno" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="Sno" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <div>
   
    </div>
    </form>
</body>
</html>

Code generate the following output

How to set outer and inner line of Gridview

DataList ItemStyle property example in ASP.NET

DataList ItemStyle property 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>
    <style type="text/css">
        #form1
        {
            width: 162px;
            height: 384px;
        }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <asp:DataList ID="DataList1" runat="server" DataKeyField="Sno" 
        DataSourceID="SqlDataSource1">
<ItemStyle BackColor="#009933" />
        <ItemTemplate>
            Sno:
            <asp:Label ID="SnoLabel" runat="server" Text='<%# Eval("Sno") %>' />
            <br />
            name:
            <asp:Label ID="nameLabel" runat="server" Text='<%# Eval("name") %>' />
            <br />
            address:
            <asp:Label ID="addressLabel" runat="server" Text='<%# Eval("address") %>' />
            <br />
<br />
        </ItemTemplate>
    </asp:DataList>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
        ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
        DeleteCommand="DELETE FROM [User] WHERE [Sno] = @Sno" 
        InsertCommand="INSERT INTO [User] ([name], [address]) VALUES (@name, @address)" 
         SelectCommand="SELECT * FROM [User]" 
        UpdateCommand="UPDATE [User] SET [name] = @name, [address] = @address WHERE [Sno] = @Sno">
        <DeleteParameters>
            <asp:Parameter Name="Sno" Type="Int32" />
        </DeleteParameters>
        <InsertParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address" Type="String" />
        </InsertParameters>
        <UpdateParameters>
            <asp:Parameter Name="name" Type="String" />
            <asp:Parameter Name="address" Type="String" />
            <asp:Parameter Name="Sno" Type="Int32" />
        </UpdateParameters>
    </asp:SqlDataSource>
    <div>
    
    </div>
    </form>
</body>
</html>

Code generate the following output


DataList ItemStyle property example in ASP.NET

C function to implement Linear Search in linked list for Data Structure

C function to implement Linear Search in linked list:

   struct NODE
    {
       int INFO;
      struct NODE *LINK;
     };
     void search_11( struct NODE *ptr, int IN)
     {
      while(ptr !=NULL && ptr-->INFO !=IN)
        ptr =ptr-->LINK;
       if (ptr-->INFO == IN)
         printf(“Search successful”);
       else
          printf(“Search unsuccessful”);
       }

Other form of C function:

   struct NODE
    {
       int INFO;
      struct NODE *LINK;
     };
    int search_11 (struct NODE *ptr, int IN)
    {
      while(ptr !=NULL)
       {
        if(ptr-->INFO == IN)
         return 1;
        ptr = ptr->LINK;
        }
      return 0;
     }

Algorithm Linear Search applied to Linked List

Algorithm:

SEARCHLl1 (ROOT, IN)
[ROOT is starting address of Linked List and 
 IN is Information to be searching in Linked List]
PTR<--ROOT
Repeat While PTR< >NULL AND IN< >PTR-->INFO
  PTR<--PTR-->LINK
[End of while]
If PTR-->INFO=IN Then:
   Write: ‘Search Successful’
Else:
   Write: ‘Search Successful’
[End of If]

Second form: 

SEARCHLL2 (ROOT, IN)
PTR<--ROOT
Repeat While PTR< >NULL AND IN< >PTR-->INFO
  PTR<--PTR-->LINK
[End of while]
If PTR-->INFO=IN Then:
  Return 1
Else:
  Return 0
[End of If]
Exit.

Linear Search applied to Linked List for Data Structure in 'C'

 Linear Search applied to Linked List

        In Linked List linear searching is nothing but finding a node with the given information for the presence. If it is present search is successful otherwise unsuccessful. Linked List supports only linear search. The main reason behind this is the inability of reaching any of the nodes directly except the first node. Only the address of the first node is always available in an external pointer. With the help of the first node only it is possible to reach the second node. Without the address of previous node one can not reach the next node. The next node’s address is always stored in previous node. Although the order of the information may in either ascending or descending but accessibility of the elements is not direct, so application of linear is only possible in case of linked list. Searching (of course linear) almost resembles traversing except that if search is successful traversing is terminated otherwise the linked list is traversed till the end.
        So, in order to do linear searching, get the information to be searching and set PTR with ROOT. Compare Information with INFO of PTR, if it is equal ‘search is successful’ and terminate traversing otherwise update PTR with LINK of PTR and repeat the process. Continue the operation till the end. The end is recognized by a NULL assigned to PTR.

Wednesday, March 19, 2014

Gridview Header row border style solid example

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 Gridview Header row border style solid using property bar



<!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="Solid" />

    </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 Generate the following output
Gridview Header row border style solid example

C function to implement Linear Search in 1-dimensional array

  C function to implement Linear Search in 1-dimensional array:

int linear_search(int arr[ ], int n, int key)
{
  int success=0,i=0; /* initial index is 0 */
  while ((i<n)&& (success == 0))
    {
       if (arr[i] == key)
       success = 1;
       i= i+1;
     }
  return success;
}

This C function returns 1 (TRUE) if the search is successful, otherwise it returns 0 (FALSE). The same function can be written using for statement compactly as follows:
int linear_search(int arr[ ], int n, int key)
{
  int success=0,i; /*initial index is 0*/
  for(i=o; i<n&& success == 0;i++)
    if(arr[i]==key)
      success = 1;
 return success;
}

If we want to display the "successful" or "unsuccessful" message in the function itself instead of returning 1 or 0, then we can just change the function code as follows:
void linear_search(int arr[ ], int n, int key)
{
  int success=0,i; /*initial index is 0 */
  for(i=0;i<n&&success == 0;i++)
   if(arr[i] == key)
    success = 1;
 if(success==1)
  printf("Search successful");
else
  printf("Search unsuccessful");
}

© Copyright 2013 Computer Programming | All Right Reserved