16,012,110 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Member 10419145 (Top 12 by date)
Member 10419145
9-Dec-13 8:23am
View
Yes
Member 10419145
5-Dec-13 8:02am
View
Thanks for your help. But by doing so the whole page is being refreshed, I donot want that to happen.
Member 10419145
5-Dec-13 6:35am
View
Where I should include this code?
Member 10419145
5-Dec-13 6:29am
View
I am not getting any error at the same time image is not stored in folder and data is not stored in DB
Member 10419145
3-Dec-13 1:40am
View
This is my coding for getting data in gridview:
Protected Sub SearchButton_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles SearchButton.Click
If IsPostBack Then
Dim sql As String
Dim adapter As New SqlDataAdapter
Dim Command As SqlCommand = New SqlCommand
Dim connection As SqlConnection = New SqlConnection("Server=pc1207;uid=sa;pwd=welcome3#;database=IRDB")
sql = "select * from tblQuestionbank "
Try
connection.Open()
Command = New SqlCommand(sql, connection)
adapter.SelectCommand = Command
adapter.Fill(ds)
'GridView1.DataSource = Command.ExecuteReader
GridView1.DataSource = ds.Tables(0)
ViewState("data") = ds.Tables(0)
GridView1.DataBind()
connection.Close()
Catch ex As Exception
End Try
End If
End Sub
And my coding for "Gridview_selectedindex" event is:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged
TextBox1.Text = GridView1.SelectedRow.Cells(1).Text
TextBox2.Text = GridView1.SelectedRow.Cells(2).Text
TextBox3.Text = GridView1.SelectedRow.Cells(3).Text
And I donot know the coding to get the image in "Image" control.
Member 10419145
29-Nov-13 6:35am
View
My coding in vb.net to retrieve image is:
Private Sub DataGridView1_CellClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellClick
Dim i As Integer
i = DataGridView1.CurrentRow.Index
If (i = DataGridView1.Rows.Count - 1) Then
Exit Sub
End If
Me.TextBox3.Text = DataGridView1.Item(1, i).Value
Me.TextBox4.Text = DataGridView1.Item(2, i).Value
Try
If Not IsDBNull(DataGridView1.Rows(e.RowIndex).Cells("Qimage").Value) Then
'Get image data from gridview column.
''Initialize image variable
Dim newImage As Image
'Read image data into a memory stream
Using ms As New MemoryStream(ReadFile(DataGridView1.Rows(e.RowIndex).Cells("Qimage").Value), 0, ReadFile(DataGridView1.Rows(e.RowIndex).Cells("Qimage").Value).Length)
ms.Write(ReadFile(DataGridView1.Rows(e.RowIndex).Cells("Qimage").Value), 0, ReadFile(DataGridView1.Rows(e.RowIndex).Cells("Qimage").Value).Length)
'Set image variable value using memory stream.
newImage = Image.FromStream(ms, True)
End Using
'set picture
PictureBox1.Image = newImage
End If
Catch ex As Exception
MessageBox.Show(ex.ToString())
End Try
End Sub
<pre lang="vb">Private Function ReadFile(ByVal sPath As String) As Byte()
'Initialize byte array with a null value initially.
Dim data As Byte() = Nothing
'Use FileInfo object to get file size.
Dim fInfo As New FileInfo(sPath)
Dim numBytes As Long = fInfo.Length
'Open FileStream to read file
Dim fStream As New FileStream(sPath, FileMode.Open, FileAccess.Read)
'Use BinaryReader to read file stream into byte array.
Dim br As New BinaryReader(fStream)
'When you use BinaryReader, you need to supply number of bytes to read from file.
'In this case we want to read entire file. So supplying total number of bytes.
data = br.ReadBytes(CInt(numBytes))
Return data
End Function</pre>
Member 10419145
29-Nov-13 5:38am
View
Hi,
I am new to asp.net and do not know how to use that can you please me?
Member 10419145
27-Nov-13 1:39am
View
On my Gridview I am getting only path of the image "C:\Documents and Settings\sathish.kumar\Desktop\RegIR_NEW\RegIR\bin\Debug\..\..\Images\5-Q-IMG.jpg" and on click of "select" link in the gridview. I must get the respective image in the image control
I tried this in Vb.net, on the Datagridview cell click event but that does not works here.
Can you help me in this?
Member 10419145
27-Nov-13 1:33am
View
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged
Try
If Not IsDBNull(GridView1.Rows(e.RowIndex).Cells("Qimage").Value) Then
'Get image data from gridview column.
''Initialize image variable
Dim newImage As Image
'Read image data into a memory stream
Using ms As New MemoryStream(ReadFile(GridView1.Rows(e.RowIndex).Cells("Qimage").Value), 0, ReadFile(GridView1.Rows(e.RowIndex).Cells("Qimage").Value).Length)
ms.Write(ReadFile(GridView1.Rows(e.RowIndex).Cells("Qimage").Value), 0, ReadFile(GridView1.Rows(e.RowIndex).Cells("Qimage").Value).Length)
'Set image variable value using memory stream.
newImage = Image.FromStream(ms, True)
End Using
'set picture
Image1.Image = newImage
End If
Catch ex As Exception
End Try
Private Function ReadFile(ByVal sPath As String) As Byte()
'Initialize byte array with a null value initially.
Dim data As Byte() = Nothing
'Use FileInfo object to get file size.
Dim fInfo As New FileInfo(sPath)
Dim numBytes As Long = fInfo.Length
'Open FileStream to read file
Dim fStream As New FileStream(sPath, FileMode.Open, FileAccess.Read)
'Use BinaryReader to read file stream into byte array.
Dim br As New BinaryReader(fStream)
'When you use BinaryReader, you need to supply number of bytes to read from file.
'In this case we want to read entire file. So supplying total number of bytes.
data = br.ReadBytes(CInt(numBytes))
Return data
End Function
On the click of "Select" in the gridview I need to get the Desired image in image control.
I tried this in Vb.net, on the Datagridview cell click event but that does not works here.
Can you help me in this?
Member 10419145
27-Nov-13 1:30am
View
On my Gridview I am getting only path of the image "C:\Documents and Settings\sathish.kumar\Desktop\RegIR_NEW\RegIR\bin\Debug\..\..\Images\5-Q-IMG.jpg" and on click of "select" link in the gridview. I must get the respective image in the image control
I tried this in Vb.net, on the Datagridview cell click event but that does not works here.
Can you help me in this?
Member 10419145
25-Nov-13 5:49am
View
Hi,
I tried this by Making the properties of Gridview "Auto Generate Select Button - True" and then I tried the below coding:
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles GridView1.SelectedIndexChanged
TextBox1.Text = GridView1.SelectedRow.Cells[1].Text
TextBox2.Text = GridView1.SelectedRow.Cells[2].Text
TextBox3.Text = GridView1.SelectedRow.Cells[3].Text
TextBox4.Text = GridView1.SelectedRow.Cells[4].Text
TextBox5.Text = GridView1.SelectedRow.Cells[5].Text
TextBox6.Text = GridView1.SelectedRow.Cells[6].Text End Sub
In these 6 textboxs, textbox 1, 2, 4, 5 are integers.
In source code I have added:
<asp:GridView ID="GridView1" runat="server" onselectedIndexChanged="GridView1_SelectedIndexChanged" Width="529px"
style="margin-top: 0px" PageSize="3"
AllowPaging="True" BorderColor="White" BorderStyle="Ridge"
SelectedIndex="0" AutoGenerateSelectButton="True">
But in coding itself I got error that "Value of type
'System.Web.UI.WebControls.TableCellCollection' cannot be converted to 'String'." and "Identifier expected."
Member 10419145
22-Nov-13 8:10am
View
I tried yours and got the desired result.
If possible can you please tell me what "viewState("data") = ds.Tables(0)" is performing.
Because I try using "GridView1.DataSource = ds.Tables(0)" directly in the "GridView1_PageIndexChanging" without using "viewState("data") = ds.Tables(0)" in "button click"
Show More