Click here to Skip to main content
15,894,646 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code.
DataSet ds = new DataSet("CpnyLgo");
byte[] MyData = new byte[0];
sda.Fill(ds, "CpnyLgo");
DataRow myRow;
myRow = ds.Tables["CpnyLgo"].Rows[0];
MyData = (byte[])myRow["CompanyLogo"];
MemoryStream stream = new MemoryStream(MyData);
picturebox1.Image=Image.Fromstream(stream);




This code is to upload the image in picturebox and i need to upload the images in grid.
I have uploaded the rest value by using this code:


C#
int i = 0;//intialises i=0
                while(QbReader1.Read())//reading the values

                    {
                        radGridView1.Rows.AddNew();//should add new row
                        //string iStr = QbReader1["CompanyName"].ToString();

                        radGridView1.Rows[i].Cells[0].Value = QbReader1["CompanyName"].ToString();
                        radGridView1.Rows[i].Cells[1].Value = Image.FromStream(stream);
                        radGridView1.Rows[i].Cells[2].Value = QbReader1["State"].ToString();
                        radGridView1.Rows[i].Cells[3].Value = QbReader1["Country"].ToString();
                        radGridView1.Rows[i].Cells[4].Value = QbReader1["WebsiteAddress"].ToString();
                        i++;
                    }



                QbReader1.Close();




Please Anyone who know the answer help me ............
Posted
Comments
Sinisa Hajnal 21-Aug-15 2:29am    
I hope you have checks and balances in your code and that this is just short version :p

Not sure about radgrid, but DataGridView has image column type which in turn has property Image which you can set. Since you already know how to create an image from datarow column, I don't see the problem. Just check exact details for radgrid.
Member 11889312 21-Aug-15 4:37am    
but i need to code it?

Really, it would not be so good to answer a question which has been asked so many times: http://www.codeproject.com/search.aspx?q=%28%22.NET%22+OR+%22C%23%22%29+database+%28image+OR+images+OR+bitmap+OR+bitmaps%29&doctypeid=1%3b5[^].

—SA
 
Share this answer
 
Comments
Member 11889312 21-Aug-15 5:15am    
what is bitmap
Sergey Alexandrovich Kryukov 21-Aug-15 10:44am    
All I can reply in response would be "have a great day!"
Is it so difficult to find out on the Web, say, Wikipedia...
—SA
hi


I get the solution.....


DataSet ds = new DataSet("CpnyLgo");
byte[] MyData = new byte[0];
sda.Fill(ds, "CpnyLgo");
DataRow myRow;
myRow = ds.Tables["CpnyLgo"].Rows[0];
MemoryStream stream = new MemoryStream(MyData);
picturebox1.Image=Image.Fromstream(stream);


<pre lang="cs">int i = 0;//intialises i=0
while(QbReader1.Read())//reading the values

{
radGridView1.Rows.AddNew();//should add new row
//string iStr =

MemoryStream stream = new MemoryStream(MyData);
picturebox1.Image=Image.Fromstream(stream);
QbReader1[&quot;CompanyName&quot;].ToString();

radGridView1.Rows[i].Cells[0].Value = QbReader1[&quot;CompanyName&quot;].ToString();
radGridView1.Rows[i].Cells[1].Value = Image.FromStream(stream);
radGridView1.Rows[i].Cells[2].Value = QbReader1[&quot;State&quot;].ToString();
radGridView1.Rows[i].Cells[3].Value = QbReader1[&quot;Country&quot;].ToString();
radGridView1.Rows[i].Cells[4].Value = QbReader1[&quot;WebsiteAddress&quot;].ToString();
i++;
}



QbReader1.Close();
</pre>
 
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