Sunday, 30 August 2015

Enable or Disable TextBox in GridVie With Footer Total When Checkbox is Checked in ASP.Net C#

Enable or Disable TextBox in GridView With Footer Total When Checkbox is Checked

GridView Row  Ckeckbox is Checked  Enable Textbox  Enter Amount Finally Get Total Footer Row Using Asp.Net C#.

                  Download Coding
                                Download

                         DEMO


                 HTML CODING

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div align="center">
       
        <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"  ShowFooter="True">
            <Columns>
                <asp:TemplateField HeaderText="Check">
                    <ItemTemplate>
                        <asp:CheckBox ID="CheckBox1" runat="server" AutoPostBack="True" OnCheckedChanged="CheckBox1_CheckedChanged" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="ID">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("id"%>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Name">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("name"%>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Quantity">
                    <ItemTemplate>
                        <asp:TextBox ID="txtQt" runat="server" Enabled="False"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Amount">
                    <FooterTemplate>
                        <asp:Label ID="lblTotal" runat="server" ForeColor="#CC3300"></asp:Label>
                        &nbsp;&nbsp;&nbsp;&nbsp;
                        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Total" />
                    </FooterTemplate>
                    <ItemTemplate>
                        <asp:TextBox ID="txtAmt" runat="server" Enabled="false"></asp:TextBox>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
    </div>
            </form>
</body>

</html>

                    C# CODING

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

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["dbcon"].ToString());
            con.Open();
            SqlDataAdapter adp = new SqlDataAdapter("select * from reg", con);
            DataSet ds = new DataSet();
            adp.Fill(ds);
            GridView1.DataSource = ds;
            GridView1.DataBind();
        }
    }
    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox chk = (CheckBox)sender;
        GridViewRow gr = (GridViewRow)chk.NamingContainer;
        CheckBox ch = (CheckBox)gr.FindControl("CheckBox1");
        TextBox txtQt = (TextBox)gr.FindControl("txtQt");
        TextBox txtAmt = (TextBox)gr.FindControl("txtAmt");
        if (chk.Checked)
        {
            txtAmt.Enabled = true;
            txtQt.Enabled = true;
        }
        else
        {
            txtQt.Text = "";
            txtAmt.Text = "";
            txtAmt.Enabled =false;
            txtQt.Enabled =false;
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {    
  
        // Footer total Button
        int total1=0;
        foreach (GridViewRow gr in GridView1.Rows)
        {
            CheckBox ch = (CheckBox)gr.FindControl("CheckBox1");
          
            if (ch.Checked & ch!=null)
            {
                TextBox txtAmt = (TextBox)gr.FindControl("txtAmt");
                Label lbltotal = GridView1.FooterRow.FindControl("lblTotal"as Label;
              total1  += Convert.ToInt32(txtAmt.Text);
              lbltotal.Text = total1.ToString();
            }       
        }
    }
  

}








































Wednesday, 19 August 2015

Parameter Pass To Report.rdlc in Temporary Values Using Asp.Net C#


Report Create & Particular Control  Pass Methods Already Use Below Links


http://screenshotdrizzles.blogspot.in/2014/10/how-to-pass-parameter-to-rdlc-report-or.html

http://screenshotdrizzles.blogspot.in/2014/10/how-to-pass-particular-control-id.html


Now Pass Without Database Values To Report.rdlc Report.

                             C# Coding

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using Microsoft.Reporting.WebForms;

public partial class reports : System.Web.UI.Page
{
   
    protected void Page_Load(object sender, EventArgs e)
    {
             if (!IsPostBack)
                {                                  
                      string  date1 = "22/10/2014";
                      string  name =  "Drizzles";
                
             ReportParameter rpt1 = new ReportParameter("id""1");
    ReportParameter rpt2 = new ReportParameter("date", date1.ToString());
 ReportParameter rpt3 = new ReportParameter("name", name.ToString());


  this.ReportViewer1.LocalReport.SetParameters(new ReportParameter[] { rpt1, rpt2, rpt3 });


        this.ReportViewer1.LocalReport.Refresh();
                  
                } 
            }
        }
     

   































Monday, 17 August 2015

Drag and Drop Gridview Row to Another GridView Row or DetailsView

One Gridview row Move To Another GridView row Display as well as Detailsview Using JQuery Asp.Net C#.

                Download Coding
                               Download

                       DEMO


                  HTML CODING

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server"> 
<style type="text/css"> 
.row
{  
background-color:hotpink;
border3px solid #ffba00;
color:Black;
}
.row td
{
cursor:move;
font-weight:bold;
}
</style>
    <title>Drag & Drop GridView To Another GridView Using Jquery</title>
    <script src="jquery-1.8.2.min.js" type="text/javascript"></script>
    <script src="jquery-ui-1.8.24.custom.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {
            var droppedItemIndex = -1;
            $('.block').draggable({
                helper: "clone",
                cursor: "move"
            });
            $('#<%=GridView2.ClientID %>').droppable({
                drop: function (ev, ui) {
                    accept: '.block',
                     droppedItemIndex = $(ui.draggable).index();
                    var droppedItem = $(".gridSrc tr").eq(droppedItemIndex);
                    index = -1;
                    $("[id*=GridView2] .name").html(droppedItem.find(".name").html());
                    $("[id*=GridView2] .designation").html(droppedItem.find(".designation").html());

                }
            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <table >
    <tr>
    <td>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            onrowcreated="GridView1_RowCreated" CssClass="gridSrc" >
            <SelectedRowStyle CssClass="block row" />
            <RowStyle CssClass="block" />
            <HeaderStyle CssClass="grd1-header" />
            <Columns>
            <asp:BoundField DataField="name" HeaderText="Name" ItemStyle-CssClass="name" >
<ItemStyle CssClass="name"></ItemStyle>
                </asp:BoundField>
             <asp:BoundField DataField="designation" HeaderText="Designation" ItemStyle-CssClass="designation" >
<ItemStyle CssClass="designation"></ItemStyle>
                </asp:BoundField>
           </Columns>
        </asp:GridView>
    </td>
    <td >
        <asp:GridView ID="GridView2"  Height="50px" Width="125px"  runat="server" AutoGenerateColumns="False" >
            <Columns>          
                <asp:TemplateField HeaderText="Name" ItemStyle-CssClass="name">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("name"%>'></asp:Label>
                    </ItemTemplate>

<ItemStyle CssClass="name"></ItemStyle>

                </asp:TemplateField>
                <asp:TemplateField HeaderText="Designation">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Eval("designation"%>'></asp:Label>
                    </ItemTemplate>
                    <ItemStyle CssClass="designation"></itemstyle>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

      
    </td>
    </tr>
</table>  
    </div>
    </form>
</body>

</html>

                    C# CODING

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

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["dbcon"].ToString());
        con.Open();
        SqlCommand cmd = new SqlCommand("select * from reg", con);
        SqlDataAdapter dAdapter = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        dAdapter.Fill(ds);
        if (ds.Tables[0].Rows.Count > 0)
        {
            GridView1.DataSource = ds.Tables[0];
            GridView1.DataBind();
        }
        DataTable dt = new DataTable();
        ds.Tables[0].Clear();
        dt = ds.Tables[0];
        dt.Rows.Add();
        GridView2.DataSource = dt;
        GridView2.DataBind();
    }   
    protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes.Add("onmouseover""this.className='row'");
            e.Row.Attributes.Add("onmouseout""this.className='block'");
        }
    }
  

}