You must Sign In to post a response.
  • Category: ASP.NET

    In runtime i need to visible the bind data in gridview in asp.net

    in a gridview i show the following data

    name adres mobile

    celv chennai 880*****

    mani Sivagangai 770763****

    if i click the print button i need to print the following data in runtime

    name adres

    celv chennai

    mani Sivagangai
  • #762328
    Hi Selvi,

    If you want to print your result then my suggestion is open your result set in new window and using javascript you can print your result by using window.print() function.


    window.print();


    Hope this will helpful to you...

    --------------------------------------------------------------------------------
    Give respect to your work, Instead of trying to impress your boss.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #762341
    Hi
    You can do one thing try to print javascript function try this code working for me.


    Step1: Sql Server Side



    Create Table TblNmlist
    (
    name varchar(40),
    adres varchar(40),
    mobile varchar(40)
    )

    Insert into TblNmlist values('celv','chennai ','880*****')
    Insert into TblNmlist values('mani','Sivagangai ','770763****')


    Select * from TblNmlist






    Aspx Page this


    <script>
    function hideColumn() {
    var gridrows = $("#Grd1 tbody tr");

    for (var i = 0; i < gridrows.length; i++) {
    gridrows[i].cells[2].style.display = "none";
    }
    window.print();
    return false;

    }


    </script>

    <asp:Button ID="bt1" runat="server" Text="Print11111" OnClick="bt1_Click" OnClientClick="return hideColumn();" />



    Server Side C# Code



    DataTable dt = new DataTable();
    SqlDataAdapter sqladp = new SqlDataAdapter("Select * from TblNmlist", con);
    sqladp.Fill(dt);
    Grd1.DataSource = dt;
    Grd1.DataBind();



    I have attached Snapshot check them

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

    Delete Attachment

  • #762352
    hi kumar vill u plz share ur source

  • #762374
    Hi

    sorry i forgot client side just copy and paste this code . if you need change this fields.


    <asp:GridView ID="Grd1" runat="server" AutoGenerateColumns="false">
    <Columns>
    <asp:BoundField DataField="name" HeaderText="name" />
    <asp:BoundField DataField="adres" HeaderText="adres" />
    <asp:BoundField DataField="mobile" HeaderText="mobile" />
    </Columns>
    </asp:GridView>

    Name : Dotnet Developer-2015
    Email Id :kumaraspcode2009@gmail.com

    'Not by might nor by power, but by my Spirit,' says the LORD Almighty.

  • #762393

    salesprint.bmp

    Delete Attachment


Sign In to post your comments