Enable or Disable TextBox in GridView 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();
            }       
        }
    }
  

}



First Create New Webform - Add GridView  From Toolbox - Edit Column - Add TemplateField -  Ok





Next - Add Header Text Name






Next - GridView Edit Template Field - Add Label - Edit DataBinding - Bind Field Name






Next - GridView Edit Template Field - Add Textbox - Property - Enable = false







After - DataBound Show GridView





Next - GridView Edit Column - Template Field 





GridView - Edit Template Field - Add Checkbox - AutoPostback =true







Checkbox - Double Click 






Next - Textbox - Enabled = false






Next - Show GridView After Bind Checkbox 






Next - Add Namespaces -  Gridview row  Event -  Checkbox is Checked - Row Event Values Get & enabled= true






Next - Get Total Values to Footer Row










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


Report Create & Particular Control  Pass Methods Already Use Below Links

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

http://dotnetdrizzles.blogspot.in/2014/10/how-to-pass-particularwhere-condition.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();
                  
                } 
            }
        }
     

   

Above Link Use to Dataset connect method 

Select - Report Viewer - Add - Report.rdlc





Next - Add - Namespaces - Pass Parameter To Report.rdlc Report






Next - Add - Report.rdlc New -  File 






Next - Repot.rdlc - File - Parameter - Right Click - Add Parameter





Add - Passing - Same - Name - Add - Datatype




Add - Required Parameters




Next - Go to ToolBox - Select - Textbox or Toolbox  -  Right Click - Select Expression 





Next - Add - Required Parameter - Double Click - OK






Next - Set to the Parameter Name






Next - Set the Required Parameter Names

Next - Run The Form Get the Report







Drag and Drop Gridview Row to Another GridView Row or DetailsView Using JQuery in Asp.Net C#

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;
border: 3px 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'");
        }
    }
  

}



First - Create New Form - Add Two GridView - Bind Data - add Edit Column - TemplateField





Add - Label For bind Field Name






JQquery  Plugins Add To  Script 






Add Item CssClass For Second GridView Item





Next - Bind Database Data To Gridview onPage Loading