Thursday, 8 May 2014

Windows Printing

 PrintDocument doc = new PrintDocument();
                doc.PrintPage += new PrintPageEventHandler(doc_PrintPage);
                PrintDialog dlgSettings = new PrintDialog();
                dlgSettings.Document = doc;
                doc.Print();

void doc_PrintPage(object sender, PrintPageEventArgs e)
        {
            try
            {
                // PictureBox abc = pictureBox1;
                Font font5 = new Font("Arial", 9);
                Font font4 = new Font("Arial", 8);
                Font font3 = new Font("Arial", 12);
                Font font2 = new Font("Arial", 9);
                Font font1 = new Font("Arial", 13);
                Font font = new Font("Arial", 10);
                Font font7 = new Font("Arial", 20);
                Font font8 = new Font("Times New Roman", 27);
                Font font6 = new Font("Arial", 17);
                Font font9 = new Font("Arial", 14);
                //float x = e.MarginBounds.Left;
                //float lineSide=font.
                float y = e.MarginBounds.Top;
                float lineHeight = font.GetHeight(e.Graphics);
                //e.Graphics.DrawImage(abc.Image, 60, 70, 50, 100);
                //e.Graphics.DrawImage(abc.Image, 650, 70, 50, 100);
                y += lineHeight;

                y += lineHeight;
                //e.Graphics.DrawImageUnscaled(adc, 0, 0, 768, 1152);
                e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", font, Brushes.Black, float.Parse("20"), float.Parse("12"));
                y += lineHeight;
                e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", font, Brushes.Black, float.Parse("20"), float.Parse("140"));
                y += lineHeight;
                e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", font, Brushes.Black, float.Parse("20"), float.Parse("260"));
                y += lineHeight;
                e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", font, Brushes.Black, float.Parse("20"), float.Parse("300"));
                y += lineHeight;
                e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", font, Brushes.Black, float.Parse("20"), float.Parse("837"));
                y += lineHeight;
                e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", font, Brushes.Black, float.Parse("20"), float.Parse("950"));
                y += lineHeight;
                e.Graphics.DrawString("-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------", font, Brushes.Black, float.Parse("20"), float.Parse("1035"));
                y += lineHeight;


                int aa = 20;
                while (aa < 1040)
                {
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("20"), float.Parse(aa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("835"), float.Parse(aa.ToString()));
                    y += lineHeight;
                    aa = aa + 12;
                }
                int aaaa = 145;
                while (aaaa < 255)
                {
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("560"), float.Parse(aaaa.ToString()));
                    y += lineHeight;

                    aaaa = aaaa + 12;
                }

                e.Graphics.DrawString("BILL BOOK", font, Brushes.Black, float.Parse("380"), float.Parse("40"));
                e.Graphics.DrawString("Mobile : 9810067502", font, Brushes.Black, float.Parse("670"), float.Parse("40"));
                e.Graphics.DrawString("PAHUJA ASSOCIATES", font8, Brushes.Black, float.Parse("228"), float.Parse("60"));

                e.Graphics.DrawString("351/1/11, New Colony More, Ratan Garden", font3, Brushes.Black, float.Parse("253"), float.Parse("100"));
                e.Graphics.DrawString("Old Railway Road, Gurgaon", font3, Brushes.Black, float.Parse("310"), float.Parse("120"));


                e.Graphics.DrawString("Date   ", font, Brushes.Black, float.Parse("570"), float.Parse("220"));
                e.Graphics.DrawString(": " + dateTimePicker1.Text, font, Brushes.Black, float.Parse("670"), float.Parse("220"));
                e.Graphics.DrawString("TIN NO.  ", font, Brushes.Black, float.Parse("30"), float.Parse("125"));
                e.Graphics.DrawString(": 06401939735", font, Brushes.Black, float.Parse("105"), float.Parse("125"));

                e.Graphics.DrawString("Name ", font, Brushes.Black, float.Parse("30"), float.Parse("155"));
                e.Graphics.DrawString(": " + textBox8.Text, font, Brushes.Black, float.Parse("100"), float.Parse("155"));

                e.Graphics.DrawString("Address", font, Brushes.Black, float.Parse("30"), float.Parse("175"));
                e.Graphics.DrawString(": ", font, Brushes.Black, float.Parse("100"), float.Parse("175"));
                //Below Code for Multiline print of Address

                string ss1 = textBox9.Text;
                int count1 = textBox9.Text.Length;
                int divlength1 = 60;
                int remainder1 = count1 % divlength1;

                int NoOfRow1 = 0;
                if (remainder1 > 0)
                {
                    NoOfRow1 = (count1 / divlength1) + 1;
                }
                else
                {
                    NoOfRow1 = count1 / divlength1;
                }
                string[] arr1 = new string[NoOfRow1];
                for (int i = 0; i < NoOfRow1; i++)
                {
                    if (i < NoOfRow1 - 1)
                    {
                        arr1[i] = ss1.Substring(60 * i, 60);
                    }
                    else
                    {
                        arr1[i] = ss1.Substring(60 * i, remainder1);
                    }
                }
                int cd1 = 175;
                for (int i = 0; i < NoOfRow1; i++)
                {
                    e.Graphics.DrawString(arr1[i], font, Brushes.Black, float.Parse("110"), float.Parse(cd1.ToString()));
                    y += lineHeight;
                    cd1 = cd1 + 20;
                }

                //===============================================
                //Customer related
                e.Graphics.DrawString("Invoice No.  ", font, Brushes.Black, float.Parse("670"), float.Parse("125"));
                e.Graphics.DrawString(": " + label24.Text, font, Brushes.Black, float.Parse("740"), float.Parse("125"));
                e.Graphics.DrawString("Dispatch Date   ", font, Brushes.Black, float.Parse("570"), float.Parse("240"));
                e.Graphics.DrawString(": " + dateTimePicker2.Text, font, Brushes.Black, float.Parse("670"), float.Parse("240"));

                e.Graphics.DrawString("P.Order No.  ", font, Brushes.Black, float.Parse("570"), float.Parse("160"));
                e.Graphics.DrawString(": " + textBox23.Text, font, Brushes.Black, float.Parse("670"), float.Parse("160"));
                e.Graphics.DrawString("VAT/TIN No.  ", font, Brushes.Black, float.Parse("570"), float.Parse("180"));
                e.Graphics.DrawString(": " + textBox18.Text, font, Brushes.Black, float.Parse("670"), float.Parse("180"));
                e.Graphics.DrawString("C.S.T No  ", font, Brushes.Black, float.Parse("570"), float.Parse("200"));
                e.Graphics.DrawString(": " + textBox13.Text, font, Brushes.Black, float.Parse("670"), float.Parse("200"));

                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));
                e.Graphics.DrawString("", font3, Brushes.Black, float.Parse("100"), float.Parse("210"));

                int aaa = 265;
                while (aaa < 840)
                {
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("20"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("83"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("250"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("290"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("350"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("410"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("450"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("510"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("580"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("620"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("660"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("700"), float.Parse(aaa.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString("|", font, Brushes.Black, float.Parse("740"), float.Parse(aaa.ToString()));
                    y += lineHeight;

                    aaa = aaa + 12;
                }
                //itemcode,itemname,noofcase,mfgperiod,mrp,qty,rate,amount,discper,vatper,surcper,netamount,pcscase
                e.Graphics.DrawString("Item Code", font5, Brushes.Black, float.Parse("25"), float.Parse("276"));

                e.Graphics.DrawString("Item Name", font5, Brushes.Black, float.Parse("105"), float.Parse("276"));

                e.Graphics.DrawString("No.Of", font5, Brushes.Black, float.Parse("255"), float.Parse("276"));
                e.Graphics.DrawString("Case", font5, Brushes.Black, float.Parse("255"), float.Parse("288"));
                e.Graphics.DrawString("Mfg.", font5, Brushes.Black, float.Parse("295"), float.Parse("276"));
                e.Graphics.DrawString("Period", font5, Brushes.Black, float.Parse("295"), float.Parse("288"));
                e.Graphics.DrawString("M.R.P", font5, Brushes.Black, float.Parse("355"), float.Parse("276"));
                e.Graphics.DrawString("Qty", font5, Brushes.Black, float.Parse("415"), float.Parse("276"));
                e.Graphics.DrawString("Rate", font5, Brushes.Black, float.Parse("455"), float.Parse("276"));
                e.Graphics.DrawString("Amount", font5, Brushes.Black, float.Parse("515"), float.Parse("276"));
                e.Graphics.DrawString("Dis.%", font5, Brushes.Black, float.Parse("585"), float.Parse("276"));

                e.Graphics.DrawString("Vat%", font5, Brushes.Black, float.Parse("625"), float.Parse("276"));

                e.Graphics.DrawString("Sur.%", font5, Brushes.Black, float.Parse("665"), float.Parse("276"));

                e.Graphics.DrawString("Pcs/", font5, Brushes.Black, float.Parse("705"), float.Parse("276"));
                e.Graphics.DrawString("Case", font5, Brushes.Black, float.Parse("705"), float.Parse("288"));
                e.Graphics.DrawString("Net Amount", font5, Brushes.Black, float.Parse("755"), float.Parse("276"));

                e.Graphics.DrawString("Amount", font, Brushes.Black, float.Parse("650"), float.Parse("850"));
                e.Graphics.DrawString("Total Vat", font, Brushes.Black, float.Parse("50"), float.Parse("880"));
                e.Graphics.DrawString("Total Surcharge", font, Brushes.Black, float.Parse("250"), float.Parse("880"));
                e.Graphics.DrawString("Total Discount", font, Brushes.Black, float.Parse("450"), float.Parse("880"));
                e.Graphics.DrawString("Total Amount", font, Brushes.Black, float.Parse("650"), float.Parse("880"));
                e.Graphics.DrawString("Scheme", font, Brushes.Black, float.Parse("50"), float.Parse("910"));
                e.Graphics.DrawString("H.C.", font, Brushes.Black, float.Parse("250"), float.Parse("910"));
                e.Graphics.DrawString("CR/DR", font, Brushes.Black, float.Parse("450"), float.Parse("910"));
                e.Graphics.DrawString("Net Amount", font, Brushes.Black, float.Parse("650"), float.Parse("910"));

                e.Graphics.DrawString(" : ", font, Brushes.Black, float.Parse("735"), float.Parse("850"));
                e.Graphics.DrawString(" : ", font, Brushes.Black, float.Parse("120"), float.Parse("880"));
                e.Graphics.DrawString(" : ", font, Brushes.Black, float.Parse("350"), float.Parse("880"));
                e.Graphics.DrawString(" : ", font, Brushes.Black, float.Parse("540"), float.Parse("880"));
                e.Graphics.DrawString(" : ", font, Brushes.Black, float.Parse("735"), float.Parse("880"));
                e.Graphics.DrawString(" : ", font, Brushes.Black, float.Parse("120"), float.Parse("910"));
                e.Graphics.DrawString(" : ", font, Brushes.Black, float.Parse("350"), float.Parse("910"));
                e.Graphics.DrawString(" : ", font, Brushes.Black, float.Parse("540"), float.Parse("910"));
                e.Graphics.DrawString(" : ", font, Brushes.Black, float.Parse("735"), float.Parse("910"));

                e.Graphics.DrawString("" + textBox7.Text, font, Brushes.Black, float.Parse("770"), float.Parse("850"));
                e.Graphics.DrawString("" + textBox14.Text, font, Brushes.Black, float.Parse("140"), float.Parse("880"));
                e.Graphics.DrawString("" + textBox15.Text, font, Brushes.Black, float.Parse("370"), float.Parse("880"));
                e.Graphics.DrawString("" + textBox16.Text, font, Brushes.Black, float.Parse("560"), float.Parse("880"));
                e.Graphics.DrawString("" + textBox11.Text, font, Brushes.Black, float.Parse("770"), float.Parse("880"));
                e.Graphics.DrawString("" + textBox17.Text, font, Brushes.Black, float.Parse("140"), float.Parse("910"));
                e.Graphics.DrawString("" + textBox19.Text, font, Brushes.Black, float.Parse("370"), float.Parse("910"));
                e.Graphics.DrawString("" + textBox20.Text, font, Brushes.Black, float.Parse("560"), float.Parse("910"));
                e.Graphics.DrawString("" + textBox21.Text, font, Brushes.Black, float.Parse("770"), float.Parse("910"));
                e.Graphics.DrawString("E. & O.E.", font, Brushes.Black, float.Parse("30"), float.Parse("960"));
                e.Graphics.DrawString("Goods once sold will not be taken back.", font, Brushes.Black, float.Parse("30"), float.Parse("1000"));

                e.Graphics.DrawString("For PAHUJA ASSOCIATES", font, Brushes.Black, float.Parse("620"), float.Parse("960"));
                e.Graphics.DrawString("Authorised Signatory", font, Brushes.Black, float.Parse("650"), float.Parse("1020"));


                int c = 320;
                for (int b = 0; b < dataGridView1.Rows.Count - 1; b++)
                {
                    // int pos5 = position(counting(dataGridView1.Rows[b].Cells[1].Value.ToString()));
                    //e.Graphics.DrawString((b + 1).ToString(), font4, Brushes.Black, float.Parse("23"), float.Parse(c.ToString()));
                    //y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[0].Value.ToString(), font5, Brushes.Black, float.Parse("25"), float.Parse(c.ToString()));
                    y += lineHeight;
                    //e.Graphics.DrawString(dataGridView1.Rows[b].Cells[1].Value.ToString(), font5, Brushes.Black, float.Parse("86"), float.Parse(c.ToString()));
                    //y += lineHeight;


                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[2].Value.ToString(), font5, Brushes.Black, float.Parse("255"), float.Parse((c).ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(Convert.ToDateTime(dataGridView1.Rows[b].Cells[3].Value).ToString("dd-MM-yy"), font5, Brushes.Black, float.Parse("295"), float.Parse(c.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[4].Value.ToString(), font5, Brushes.Black, float.Parse("355"), float.Parse(c.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[5].Value.ToString(), font5, Brushes.Black, float.Parse("415"), float.Parse(c.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[6].Value.ToString(), font5, Brushes.Black, float.Parse("455"), float.Parse(c.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[7].Value.ToString(), font5, Brushes.Black, float.Parse("515"), float.Parse(c.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[8].Value.ToString(), font5, Brushes.Black, float.Parse("585"), float.Parse(c.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[10].Value.ToString(), font5, Brushes.Black, float.Parse("625"), float.Parse(c.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[12].Value.ToString(), font5, Brushes.Black, float.Parse("665"), float.Parse(c.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[15].Value.ToString(), font5, Brushes.Black, float.Parse("705"), float.Parse(c.ToString()));
                    y += lineHeight;
                    e.Graphics.DrawString(dataGridView1.Rows[b].Cells[14].Value.ToString(), font5, Brushes.Black, float.Parse("755"), float.Parse(c.ToString()));
                    y += lineHeight;

                    //Below Code for Multiline print of Item Name

                    string ss = dataGridView1.Rows[b].Cells[1].Value.ToString();
                    int count = dataGridView1.Rows[b].Cells[1].Value.ToString().Length;
                    int divlength = 23;
                    int remainder = count % divlength;

                    int NoOfRow = 0;
                    if (remainder > 0)
                    {
                        NoOfRow = (count / divlength) + 1;
                    }
                    else
                    {
                        NoOfRow = count / divlength;
                    }
                    string[] arr = new string[NoOfRow];
                    for (int i = 0; i < NoOfRow; i++)
                    {
                        if (i < NoOfRow - 1)
                        {
                            arr[i] = ss.Substring(23 * i, 23);
                        }
                        else
                        {
                            arr[i] = ss.Substring(23 * i, remainder);
                        }
                    }

                    for (int i = 0; i < NoOfRow; i++)
                    {
                        e.Graphics.DrawString(arr[i], font, Brushes.Black, float.Parse("86"), float.Parse(c.ToString()));
                        y += lineHeight;
                        c = c + 20;
                    }
                    //======================================================

                    //c = c + 15;
                }

            }
            catch (Exception)
            {
            }
        }

Dynamic Slider

 <td>
    <div class="slider-wrapper theme-default">

      <div class="ribbon"></div>

        <div id="slider" class="nivoSlider">

         
            <asp:Repeater ID="Repeater2" runat="server">
            <ItemTemplate>
            <div>              
            <asp:Image ID="Image2" Width="890px" Height="405px" ImageUrl='<%#Eval("Image") %>' runat="server" />
            </div>

            </ItemTemplate>
            </asp:Repeater>
    </div>
    </div>
    </td>

Code

  da = new SqlDataAdapter("select * from slider", con);
        dt = new DataTable();
        da.Fill(dt);
        Repeater2.DataSource = dt;
        Repeater2.DataBind();

Enquiry Form

try
        {

            MailMessage message = new MailMessage();
            SmtpClient sc = new SmtpClient();
            message.To.Add("info@syncretize.in");
            message.Subject = "Contact";
            message.IsBodyHtml = true;

            message.From = new MailAddress("enquiryfromwebsite@tansensangeet.com");
            sc.Host = "smtp.gmail.com";
            sc.Port = 587;
            sc.EnableSsl = true;
            sc.UseDefaultCredentials = false;
            sc.Credentials = new NetworkCredential("enquiryfromwebsite@tansensangeet.com", "parallels");
            string htmlbody = "";
            htmlbody = "<HTML>";
            htmlbody = htmlbody + "<HEAD>";
            htmlbody = htmlbody + "</HEAD>";
            htmlbody = htmlbody + "<BODY>";

            htmlbody = htmlbody + "<br>";
            htmlbody = htmlbody + "Name: " + TextBox1.Text;
            htmlbody = htmlbody + "<br>";
            htmlbody = htmlbody + "Email From: " + TextBox3.Text;
            htmlbody = htmlbody + "<br>";
            htmlbody = htmlbody + "Mobile No.: " + TextBox2.Text;
            htmlbody = htmlbody + "<br>";
            htmlbody = htmlbody + "Message: " +TextBox4.Text;
            htmlbody = htmlbody + "<br>";
            htmlbody = htmlbody + "<br>";
            htmlbody = htmlbody + "<br>";
            htmlbody = htmlbody + "</BODY>";
            htmlbody = htmlbody + "</HEAD>";
            htmlbody = htmlbody + "</HTML>";
            message.Body = htmlbody;


            sc.Send(message);
            TextBox1.Text = "";
            TextBox2.Text = "";
            TextBox3.Text = "";
            TextBox4.Text = "";
            Label14.Visible = true;
            //Response.Write("<script>alert('Thank You for taking the time to Syncretize')</scrip>");




        }
        catch (Exception)
        {
            Label14.Visible=true;
            Label14.Text = "Message Not Sent";
        }
    }

Bind Table through Dataset

public DataSet ds;

protected void Page_Load(object sender, EventArgs e)
{
    ds = new DataSet();
    //load your ds from database
}
Following is the code to use table 0 from database to create table in aspx
<table>
<% foreach(DataRow row in ds.Tables[0].Rows) { %>
<tr>
<td><%= row["columnName"] %></td>
</tr>
<% } %>
</table>

Design in datalist

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Management.aspx.cs" Inherits="Management" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <table width="100%">
        <tr>
            <td>
                <table width="30%" align="left">
                    <tr>
                        <td align="left">
                            <asp:DataList ID="DataList1" Width="80%" runat="server" RepeatColumns="1" OnItemCommand="DataList1_ItemCommand" BackColor="White">
                                <ItemTemplate>
                                    <asp:LinkButton ID="LinkButton1" Text='<%#Eval("Name") %>' CommandName="name" CommandArgument='<%#Eval("Name") %>' runat="server" Font-Size="17px" Font-Bold="true" ForeColor="Black">LinkButton</asp:LinkButton>
                                 
                                    <br />
                                    <asp:Label ID="Label2" runat="server" Text='<%#Eval("post") %>'></asp:Label><hr  style="border-top-style: solid; border-top-color: #000000; border-right-color: #000000; border-bottom-color: #000000; border-left-color: #000000; border-top-width: 1px;" />
                                </ItemTemplate>
                            </asp:DataList>
                        </td>
                    </tr>
                </table>
                <table width="70%">
                    <tr>
                        <td align="left">
                            <asp:DataList ID="DataList2" runat="server" Width="100%">
                                <ItemTemplate>
                                    <table width="100%">
                                        <tr>
                                            <td width="30%">
                                <asp:Image ID="Image1" runat="server" ImageUrl='<%#Eval("image") %>' />
                                    <br />
                                     <asp:Label ID="Label1" runat="server" Text='<%#Eval("Name") %>' Font-Bold="true" ForeColor="black" ></asp:Label>
                                    <br />
                                    <asp:Label ID="Label2" runat="server" Text='<%#Eval("post") %>'></asp:Label>
                                            </td>
                                            <td width="70%">
                                                 <asp:Label ID="Label3" runat="server" Text='<%#Eval("Description") %>'></asp:Label>
                                            </td>
                                        </tr>
                                    </table>
                                 
                                </ItemTemplate>
                            </asp:DataList>
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
</asp:Content>


Code

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;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Configuration;
public partial class Management : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());

    SqlDataAdapter da;
    SqlCommand cmd;
    DataTable dt;
    protected void Page_Load(object sender, EventArgs e)
    {
        datashow1();
        //datashow2();
        datashow3();
    }
    public void datashow1()
    {
        try
        {
            da = new SqlDataAdapter("select   *from management", con);
            dt = new DataTable();
            da.Fill(dt);
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }
        catch (Exception)
        {
        }

    }
    public void datashow2()
    {
        try
        {
            da = new SqlDataAdapter("select top(1) *from management where Name='"+Session["name"].ToString()+"'", con);
            dt = new DataTable();
            da.Fill(dt);
            DataList2.DataSource = dt;
            DataList2.DataBind();
        }
        catch (Exception)
        {
        }

    }
    public void datashow3()
    {
        try
        {
            da = new SqlDataAdapter("select top(1) *from management", con);
            dt = new DataTable();
            da.Fill(dt);
            DataList2.DataSource = dt;
            DataList2.DataBind();
        }
        catch (Exception)
        {
        }

    }
    protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
    {
        if (e.CommandName == "name")
        {
            Session["name"]=e.CommandArgument.ToString();
            //Response.Redirect("Management.aspx");
            datashow2();
        }
    }
}

How to insert data image and text

<center>
<h1 style="color:#CCCCCC">Infrastructure Admin</h1>
<br />
<table>
    <tr>
        <td style="width:100px">
            <asp:Label ID="Label1" Font-Bold="true" Font-Size="Larger" ForeColor="#CCCCCC" runat="server" Text="Image 1"></asp:Label>
        </td>
        <td>
            <asp:FileUpload ID="FileUpload1" ForeColor="#CCCCCC" runat="server" />
        <br /><br /></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label7" Font-Bold="true" Font-Size="Larger" ForeColor="#CCCCCC" runat="server" Text="Image 2"></asp:Label>
        </td>
        <td>
            <asp:FileUpload ID="FileUpload3" ForeColor="#CCCCCC" runat="server" />
        <br /><br /></td>
    </tr>
    <tr>
        <td>
            <asp:Label ID="Label2" Font-Bold="true" Font-Size="Larger" ForeColor="#CCCCCC" runat="server" Text=" Name"></asp:Label>
        </td>
        <td>
            <asp:TextBox ID="TextBox1" Height="20px" Width="150px" runat="server"></asp:TextBox>
      <br /><br />  </td>
    </tr>
   
    <tr>
        <td>
       
        </td>
        <td  >
            <asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
        <br /><br /></td>
    </tr>
</table>
    <br />
     <asp:GridView ID="GridView1" AutoGenerateColumns="False" DataKeyNames="id"  runat="server"
         CellPadding="4" ForeColor="#333333"
        GridLines="None" onrowcancelingedit="GridView1_RowCancelingEdit"
        onrowdeleting="GridView1_RowDeleting" onrowediting="GridView1_RowEditing"
        onrowupdating="GridView1_RowUpdating">
        <AlternatingRowStyle BackColor="White" />
       <Columns>
       <asp:TemplateField >
                <HeaderTemplate>
                    <asp:Label ID="Label4" runat="server" Width="100px" Text="Image 1"></asp:Label>
                </HeaderTemplate>
            <ItemTemplate>
                <asp:Label ID="Label15" runat="server" Visible="false" Text='<%#Eval("image1") %>'></asp:Label>
                  <asp:Image ID="Image1" Height="80px" Width="100px" runat="server" ImageUrl='<%#Eval("image1") %>' />
            </ItemTemplate>
            <EditItemTemplate>
                        <asp:Label ID="Label1" runat="server" Visible="false"  Text='<%#Eval("image1") %>'></asp:Label>
                        <asp:Image ID="Image2" Height="80px" Width="100px" runat="server" ImageUrl='<%#Eval("image1") %>' /><br />
                    <asp:FileUpload ID="FileUpload2" runat="server" />
                </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField>
                <HeaderTemplate>
                    <asp:Label ID="Label4" runat="server" Width="100px" Text="Image 2"></asp:Label>
                </HeaderTemplate>
            <ItemTemplate>
                <asp:Label ID="Label156" runat="server" Visible="false" Text='<%#Eval("image2") %>'></asp:Label>
                  <asp:Image ID="Image3" Height="80px" Width="100px" runat="server" ImageUrl='<%#Eval("image2") %>' />
            </ItemTemplate>
            <EditItemTemplate>
                        <asp:Label ID="Label110" runat="server" Visible="false"  Text='<%#Eval("image2") %>'></asp:Label>
                        <asp:Image ID="Image4" Height="80px" Width="100px" runat="server" ImageUrl='<%#Eval("image2") %>' /><br />
                    <asp:FileUpload ID="FileUpload4" runat="server" />
                </EditItemTemplate>
         </asp:TemplateField>

        <asp:TemplateField>
        <HeaderTemplate>
                    <asp:Label ID="Label115" runat="server" Width="100px" Text="Package Name"></asp:Label>
                </HeaderTemplate>
            <ItemTemplate>
                <asp:Label ID="Label6" runat="server" Text='<%#Eval("c_name") %>'></asp:Label>
            </ItemTemplate>
            <EditItemTemplate>
                <asp:TextBox ID="TextBox5" Text='<%#Eval("c_name") %>' runat="server"></asp:TextBox>
            </EditItemTemplate>
         </asp:TemplateField>
         <asp:TemplateField HeaderStyle-HorizontalAlign="Left" HeaderStyle-Height="30px">
                <HeaderTemplate>
                    <asp:Label ID="Label13" runat="server" Width="190px" Text="Operations"></asp:Label>
                </HeaderTemplate>

                <ItemTemplate>
                    <br />
                    <asp:LinkButton   ID="LinkButton1" runat="server"  CommandName="edit">Edit</asp:LinkButton>
                    <asp:LinkButton   ID="LinkButton2" runat="server"    CommandName="delete">Delete</asp:LinkButton>
                </ItemTemplate>

                <EditItemTemplate>
                    <br />
                    <asp:LinkButton   ID="LinkButton3" runat="server"    CommandName="update">Update</asp:LinkButton>
                    <asp:LinkButton   ID="LinkButton4" runat="server"    CommandName="cancel">Cancel</asp:LinkButton>
                </EditItemTemplate>



            </asp:TemplateField>

       
       </Columns>
        <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
        <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
        <SortedAscendingCellStyle BackColor="#FDF5AC" />
        <SortedAscendingHeaderStyle BackColor="#4D0000" />
        <SortedDescendingCellStyle BackColor="#FCF6C0" />
        <SortedDescendingHeaderStyle BackColor="#820000" />
    </asp:GridView>
    </center>

Code

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;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Configuration;
public partial class Default2 : System.Web.UI.Page
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ToString());

    SqlDataAdapter da;
    SqlCommand cmd;
    DataTable dt;
    protected void Page_Load(object sender, EventArgs e)
    {
         try
            {
                if (!IsPostBack)
                {
                    if (Session["username"] == null)
                    {
                        Response.Redirect("adminlogin.aspx");
                    }

                    datashow();
                }
            }
            catch (Exception ex)
            {

            }
           

     
    }
    public void datashow()
    {
        try
        {
            da = new SqlDataAdapter("select  * from infrastructure", con);
            dt = new DataTable();
            da.Fill(dt);
            GridView1.DataSource = dt;
            GridView1.DataBind();
        }
        catch (Exception)
        {
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        try
        {
            string duplicate = "image" + "/" + FileUpload1.FileName;
            string completePath = Server.MapPath(duplicate); // or  string completePath = Server.MapPath("images/Desert.jpg");

            if (System.IO.File.Exists(completePath))
            {
                Response.Write("<script language=javascript>alert('Image Name Already Exist') </script>");

            }
            else
            {
                cmd = new SqlCommand("insert into infrastructure(image1,image2,c_name) values(@image1,@image2,@c_name)", con);

                if (FileUpload1.HasFile)
                {
                    string im = "franchimag" + "/" + FileUpload1.FileName;

                    cmd.Parameters.AddWithValue("@image1", im);

                    string s = Server.MapPath("franchimag");
                    s = s + "/" + FileUpload1.FileName;
                    FileUpload1.SaveAs(s);
                }
                if (FileUpload3.HasFile)
                {
                    string im = "franchimag" + "/" + FileUpload3.FileName;

                    cmd.Parameters.AddWithValue("@image2", im);

                    string s = Server.MapPath("franchimag");
                    s = s + "/" + FileUpload3.FileName;
                    FileUpload3.SaveAs(s);
                }
                cmd.Parameters.Add("@c_name", TextBox1.Text);
               


                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();
                datashow();
            }
        }
        catch (Exception)
        {
        }

    }
    protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    {
        try
        {
            GridView1.EditIndex = -1;
            datashow();
        }
        catch (Exception)
        {
        }
    }
    protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
    {
        try
        {
            cmd = new SqlCommand("delete from infrastructure where id=@id", con);
            cmd.Parameters.Add("@id", SqlDbType.BigInt).Value = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);

            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();

            // Below code for deleting image from server folder
            Label txt = ((Label)(GridView1.Rows[e.RowIndex].FindControl("Label15")));
            string del = txt.Text;
            string completePath = Server.MapPath(del); // or  string completePath = Server.MapPath("images/Desert.jpg");

            if (System.IO.File.Exists(completePath))
            {

                System.IO.File.Delete(completePath);

            }

            datashow();
        }
        catch (Exception)
        {
        }
    }
    protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
    {
        try
        {

            GridView1.EditIndex = e.NewEditIndex;
            datashow();
        }
        catch (Exception)
        {
        }
    }
    protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        try
        {
            cmd = new SqlCommand("update infrastructure set image1=@image1,image2=@image2,c_name=@c_name where id=@id", con);

            cmd.Parameters.Add("@Id", SqlDbType.BigInt).Value = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value);

            FileUpload f2 = ((FileUpload)(GridView1.Rows[e.RowIndex].FindControl("FileUpload2")));
         
            if (f2.HasFile)
            {
                string ss = "franchimag" + "/" + f2.FileName;
                cmd.Parameters.Add("@image1", SqlDbType.NVarChar).Value = ss;

                string s = Server.MapPath("franchimag");
                s = s + "/" + f2.FileName;
                f2.SaveAs(s);
            }
                else
            {
                string lb = ((Label)(GridView1.Rows[e.RowIndex].FindControl("Label1"))).Text;
                cmd.Parameters.Add("@image1", SqlDbType.NVarChar).Value = lb;
            }
            FileUpload f3 = ((FileUpload)(GridView1.Rows[e.RowIndex].FindControl("FileUpload4")));
            if (f3.HasFile)
            {
                string ss = "franchimag" + "/" + f3.FileName;
                cmd.Parameters.Add("@image2", SqlDbType.NVarChar).Value = ss;

                string s = Server.MapPath("franchimag");
                s = s + "/" + f3.FileName;
                f3.SaveAs(s);
            }
            else
            {
                string lb = ((Label)(GridView1.Rows[e.RowIndex].FindControl("Label110"))).Text;
                cmd.Parameters.Add("@image2", SqlDbType.NVarChar).Value = lb;
            }

            cmd.Parameters.Add("@c_name", SqlDbType.NVarChar).Value = ((TextBox)(GridView1.Rows[e.RowIndex].FindControl("TextBox5"))).Text;
           

            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();
            GridView1.EditIndex = -1;
            datashow();
        }
        catch (Exception)
        {
        }
    }
}

How to Make Dynamic

<li><a href="#">Franchisee</a>
<ul>
<li>
                                <asp:DataList ID="DataList2" runat="server" OnItemCommand="DataList2_ItemCommand">
                                    <ItemTemplate>
                                        <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%#Eval("Product_Name") %>' CommandName="pn" Text='<%#Eval("Product_Name") %>'></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:DataList></li>
<li><a href="Refurbished.aspx">REFURBISHED TRUCKS </a></li>
</ul>
</li>

public void datashow()
    {
        try
        {
            da = new SqlDataAdapter("select Product_Name from Product", con);
            dt = new DataTable();
            da.Fill(dt);
            DataList1.DataSource = dt;
            DataList1.DataBind();
        }
        catch (Exception)
        {
        }

    }