<asp:GridView ID="Grid_product" runat="server" OnRowDataBound="Grid_product_RowDataBound"  AutoGenerateColumns="true">
  </asp:GridView>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                ArrayList arrl = new ArrayList();
                arrl.Add("Profit"); arrl.Add("Lost"); arrl.Add("Null");                                 arrl.Add("Null"); arrl.Add("Lost"); arrl.Add("Profit"); al.Add("Profit");                this.Grid_product.DataSource = arrl;
                this.Grid_product.DataBind();
            }
        }

 protected void Grid_product_RowDataBound(object sender, Grid_productRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                if (e.Row.Cells[0].Text == "Profit")
                {
                    e.Row.Cells[0].ForeColor = System.Drawing.Color.Red;
                }
                else if (e.Row.Cells[0].Text == "Lost")
                {
                    e.Row.Cells[0].ForeColor = System.Drawing.Color.Black;
                }
                else
                {
                    e.Row.Cells[0].ForeColor = System.Drawing.Color.Green;
                }
            }
        }
the javascript on code behind alert message with page redirect on the following code

ScriptManager.RegisterStartupScript(this,this.GetType(),"redirect",
"alert('Registration Successfully !'); window.location='" + 
Request.ApplicationPath + "Default.aspx';",true);

This is a program code which will provide info about -Ajax calender extender with java script to the developer.It will mostly used to select dates like birthdate.If user wants to select any dates prior to current date then s/he will not able to select any future date.


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>devloper4u</title>

    <script type="text/javascript">
        function CurrentDateShowing(e) {
            if (!e.get_selectedDate() || !e.get_element().value)
                e._selectedDate = (new Date()).getDateOnly();
        }     
    </script>

    <script type="text/javascript">
        function CheckDateEalier(sender, args) {
            if (sender._selectedDate > new Date()) {
                alert("Day earlier than today cannot be selected.");
                sender._selectedDate = new Date();
                sender._textbox.set_Value(sender._selectedDate.format(sender._format))
            }
        }
        
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <div>
      <asp:TextBox ID="txtDOB" runat="server"></asp:TextBox>
                                <asp:ImageButton ID="Imgbutton1" runat="server" ImageUrl="~/images/Calendar_scheduleHS.png" />
                                <cc1:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd/MM/yyyy" PopupButtonID="Imgbutton1"
 TargetControlID="txtDOB" OnClientDateSelectionChanged="CheckDateEalier">
                                </cc1:CalendarExtender>
    </div>
    </form>
</body>
</html>

put the javascript on the header Part 


  <script type="text/javascript" language="javascript">
        function callprinter(p) {
            var k = document.getElementById(p);
            var wp = window.open('', '', 'left=1000,top=1000,width=800,height=1280,toolbar=0,scrollbars=0,status=0');
            wp.document.write(k.innerHTML);
            wp.document.close();
            wp.print();
        }
    </script>

put the code in Body part 

 <div id="print11" style="width: 100%; border: 2px solid #ccc; background-color: #fff">

if you selected section on design hear in this div 

</div>

Button On Click To Print 


 <asp:Button ID="lnkprint" runat="server" Text="Print"  Width="100px"
                    OnClientClick="javascript:callprinter('print11');"  />



CREATE PROCEDURE dbo.Delete_register_mst
@intglcode int
AS
delete from register_mst
where intglcode=@intglcode
RETURN

CREATE PROCEDURE dbo.update_property_photo
@intglcode int,
@title varchar(MAX),
@description varchar(MAX),
@image_name varchar(MAX),
@date_time datetime

AS
update add_property_photo_mst set

title = @title,
description = @description,
image_name = @image_name,
date_time = @date_time
where intglcode = @intglcode

RETURN

MODBUS is an application layer messaging protocol, positioned at level 7 of the OSI model,
that provides client/server communication between devices connected on different types of
buses or networks.
The industry’s serial de facto standard since 1979, MODBUS continues to enable millions of
automation devices to communicate. Today, support for the simple and elegant structure of
MODBUS continues to grow. The Internet community can access MODBUS at a reserved
system port 502 on the TCP/IP stack.
MODBUS is a request/reply protocol and offers services specified by function codes.
MODBUS function codes are elements of MODBUS request/reply PDUs. The objective of this
document is to describe the function codes used within the framework of MODBUS
transactions.
MODBUS is an application layer messaging protocol for client/server communication between
devices connected on different types of buses or networks.
It is currently implemented using:

  •  TCP/IP over Ethernet. See MODBUS Messaging Implementation Guide V1.0a.
  •  Asynchronous serial transmission over a variety of media (wire : EIA/TIA-232-E, EIA-422, EIA/TIA-485-A; fiber, radio, etc.)
  • MODBUS PLUS, a high speed token passing network.



          A stored procedure is nothing more than prepared SQL code that you save so you can reuse the code over and over again.  So if you think about a query that you write over and over again, instead of having to write that query each time you would save it as a stored procedure and then just call the stored procedure to execute the SQL code that you saved as part of the stored procedure.

     CREATE PROCEDURE dbo.insert_student
    @Stud_name    varchar(MAX),
    @Stud_roll_no varchar(MAX)
AS
   insert into student_data
   (
       Stud_name ,
       Stud_roll_no
    )
values
    (
         @Stud_name ,
         @Stud_roll_no
     )
       RETURN
    
By providing these properties to your button you can completely remove

BORDER of your button control. The flat-style button property is the
 
best property to set when you are working with custom button control.

you have to define this property into  Page load method.

Btnsubmit.TabStop = false;
Btnsubmit.FlatStyle = FlatStyle.Flat;
Btnsubmit.FlatAppearance.BorderSize = 0;
Btnsubmit.FlatAppearance.BorderColor = Color.FromArgb(0, 255, 255, 255);



used ifream in asp.net in the all the part of outer website access all data

<div style="height:100%; width:100%">
<iframe id="MyIframe" runat="server" src="http://devloper4u.blogspot.in/"
scrolling="auto" frameborder="0" style=" overflow:scroll;
 width:100%; height:100%;"  ></iframe>
</div>
in this code to not working with login or submit in to direct 
submit or login with enter key to press
 
 
 
 
 <script type="text/javascript">
//attempting to capture keypress for chrome here but this is not working
        $("#txtContainer").keypress(function (e) {
            if (e.keyCode == '13') {
                e.preventDefault();
                doClick(buttonname, e);
                return false;
            }
        });

        function doClick(buttonName, e) {

            var key;
            if (window.event)
                key = window.event.keyCode;     //IE
            else
                key = e.which;     //firefox

            if (key == 13) {
                var btn = document.getElementById(buttonName);
                if (btn != null) { 
                    btn.click();
                    event.keyCode = 0
                } 
            }
        }
</script>
In Previous posts I explained lot of articles regarding Gridview. Now I will explain how to implement beautiful looking gridview and filter gridview records with dropdownlist selection using asp.net. To implement this first design the table in database and give name UserInfomation

ColumnName
DataType
UserId
Int(set identity property=true)
UserName
varchar(50)
LastName
varchar(50)
Location
varchar(50)
After completion table creation write some of css classes to change the appearance of gridview and design aspx page like this
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title> Beautiful Gridview theme with Filtering option</title>
<%--Styles to Change the appearance of Girdview --%>
<style type="text/css">
.GridviewDiv {font-size: 100%; font-family: 'Lucida Grande', 'Lucida Sans Unicode', Verdana, Arial, Helevetica, sans-serif; color: #303933;}
Table.Gridview{border:solid 1px #df5015;}
.GridviewTable{border:none}
.GridviewTable td{margin-top:0;padding: 0; vertical-align:middle }
.GridviewTable tr{color: White; background-color: #df5015; height: 30px; text-align:center}
.Gridview th{color:#FFFFFF;border-right-color:#abb079;border-bottom-color:#abb079;padding:0.5em 0.5em 0.5em 0.5em;text-align:center
.Gridview td{border-bottom-color:#f0f2da;border-right-color:#f0f2da;padding:0.5em 0.5em 0.5em 0.5em;}
.Gridview tr{color: Black; background-color: White; text-align:left}
:link,:visited { color: #DF4F13; text-decoration:none }
</style>
</head>
<body>
<form id="form1" runat="server">
<div class="GridviewDiv">
<table style="width: 420px" border="0" cellpadding="0" cellspacing="1" class="GridviewTable">
<tr >
<td style="width: 40px;">
UserId
</td>
<td style="width: 120px;" >
LastName
</td>
<td style="width: 130px;">
UserName
</td>
<td style="width: 130px;">
Location
</td>
</tr>
<tr >
<td style="width: 40px;">
</td>
<td style="width: 120px;">
</td>
<td style="width: 130px;">
<asp:DropDownList ID="ddlUserName" runat="server" DataSourceID="dsUserName" DataValueField="UserName" AutoPostBack="true" Width="120px" Font-Size="11px" AppendDataBoundItems="true">
<asp:ListItem Text="All" Value="%"/>
</asp:DropDownList>
</td>
<td style="width: 130px;">
<asp:DropDownList ID="ddlLocation" runat="server" DataSourceID="dsLocation" DataValueField="Location" AutoPostBack="true" Width="120px" Font-Size="11px" AppendDataBoundItems="true">
<asp:ListItem Text="All" Value="%"/>
</asp:DropDownList>
</td>
</tr>
<tr>
<td colspan="4">
<asp:GridView runat="server" ID="gvdetails" ShowHeader="false" AllowPaging="true" PageSize="10" DataSourceID="dsdetails" AutoGenerateColumns="false" Width="420px"  CssClass="Gridview">
<Columns>
<asp:BoundField DataField="UserId" HeaderText="UserId" ItemStyle-Width="40px" />
<asp:BoundField DataField="LastName" HeaderText="LastName" ItemStyle-Width="120px" />
<asp:BoundField DataField="UserName" HeaderText="UserName" ItemStyle-Width="130px"/>
<asp:BoundField DataField="Location" HeaderText="Location" ItemStyle-Width="130px"/>
</Columns>
</asp:GridView>
</td>
</tr>
</table>
</div>
<asp:SqlDataSource ID="dsUserName" runat="server" ConnectionString="<%$ConnectionStrings:dbconnection %>" SelectCommand="Select Distinct UserName from UserInformation"></asp:SqlDataSource>
<asp:SqlDataSource ID="dsLocation" runat="server" ConnectionString="<%$ConnectionStrings:dbconnection %>" SelectCommand="Select Distinct Location from UserInformation"></asp:SqlDataSource>
<asp:SqlDataSource ID="dsdetails" runat="server" ConnectionString="<%$ConnectionStrings:dbconnection %>" SelectCommand="select * from UserInformation" FilterExpression=" UserName Like '{0}%' and Location Like '{1}%'">
<FilterParameters>
<asp:ControlParameter Name="UserName" ControlID="ddlUserName" PropertyName="SelectedValue" />
<asp:ControlParameter Name="Location" ControlID="ddlLocation" PropertyName="SelectedValue" />
</FilterParameters>
</asp:SqlDataSource>
</form>
</body>
</html>
If you observe above code in header section I written css classes by using those we can change the appearance of gridview and written code to bind dropdownlists, gridview and bind the gridview records based on dropdownlists selection.
Here don’t forgot to set the connection string in web.config file here I am getting database connection from web.config file for that reason you need to set the connectionstring in web.config file like this
<connectionStrings>
<add name="dbconnection" connectionString="Data Source=sagar;Integrated Security=true;Initial Catalog=MySampleDB"/>
</connectionStrings>