Click here to Skip to main content
15,921,622 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
<pre lang="c#">
hello
How to add image in Data Grid View Cell Using C#.net
Posted

Derive a specific DataGridViewImageButtonDeleteCell class from the abstract DataGridViewImageButtonCell class.
Override the abstract LoadImages() method with a new method that loads the images that represent what this new cell's action does.

C#
public class DataGridViewImageButtonDeleteCell : DataGridViewImageButtonCell
{
    public override void LoadImages()
    {
        _buttonImageNormal = Image.FromFile("C:\\testimg.bmp");
 
    }
}
 
Share this answer
 
hi try this

XML
<asp:datalist id=""DataList1"" runat=""server"" mode="hold" xmlns:asp="#unknown" />            <ItemTemplate>
                <asp:Image ID="Image1" runat="server" ImageUrl='<%# Eval("ImageUrl", "~/Images\\{0}") %>' /><br />



and give code in page load..
SqlConnection con=new SqlConnection(..........etc);
 SqlCommand cmd = new SqlCommand();
            

            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "select * from tablename";
           

           


            cmd.Connection = con;
            con.Open();


            DataTable dt = new DataTable();
            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);

            DataList1.DataSource = dt;
            DataList1.DataBind();

            cmd.Dispose();
            con.Close();



if it is your solution
vote and accept
thanks
 
Share this answer
 
v3
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900