0

i need to add a column in gridview..
the column should contain image of the person..and the name of the image is to be taken from database.

eg:
table:tbl_Details
columns: Picture:ee.jpg
Name:abcd
Age:20
Address:"abc street"

the picture ee.jpg is saved in a folder "Images" in the Website.

could someone help me...to find a solution for this... please..

2
Contributors
1
Reply
11
Views
6 Years
Discussion Span
Last Post by abelLazm
0

if you want to add unbound columns in datagridview please check this this contains a complete example. And if you want to add columns and rows from dataset then try following code

conString = "Data Source=(local);Initial Catalog=Northwind;Integrated Security=True";
            con = new SqlConnection(conString);
            con.Open();
            string quryString = " select * from Employees";
            da = new SqlDataAdapter(quryString, con);
            ds = new DataSet();
            da.Fill(ds, "Emp");

if you want to add rows by using datasource method try this

dataGridView1.DataSource = ds.Tables["Emp"];

and if you want to add row by row data in datagridview try the following code

dataGridView1.Columns.Add("EmpID", "ID");
            dataGridView1.Columns.Add("FirstName", "FirstName");
            dataGridView1.Columns.Add("LastName", "LastName");
            int row = ds.Tables["Emp"].Rows.Count - 1;
            for (int r = 0; r<= row; r++)
            {
                dataGridView1.Rows.Add();
                dataGridView1.Rows[r].Cells[0].Value = ds.Tables["Emp"].Rows[r].ItemArray[0];
                dataGridView1.Rows[r].Cells[1].Value = ds.Tables["Emp"].Rows[r].ItemArray[1];
                dataGridView1.Rows[r].Cells[2].Value = ds.Tables["Emp"].Rows[r].ItemArray[2];
}

Edited by abelLazm: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.