How to get value when double click on image displayed in grid view and after double click get image id from data base oracle ?
My VB CODE IS GIVEN BELOW
Imports System.Data
Imports System.IO
Imports System.Data.OleDb
Imports System.Data.OracleClient
Imports System.Web.UI.WebControls
Imports t_tool
Imports System.Web.UI.UserControl
Partial Class ShapeInGrid
Inherits System.Web.UI.Page
Dim con As New OracleConnection(ConfigurationManager.ConnectionStrings("OracleConnect1").ConnectionString)
Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
con.Open()
MsgBox(con.State)
If Not IsPostBack Then
populatedata()
End If
End Sub
Private Sub populatedata()
Try
Dim sql As String
sql = "select CTD_ORDER_ID, CTD_SHAPE_IMG from V_CAB_TAG_DTLS"
Dim da As New OracleDataAdapter(Sql, con)
Dim dt As New DataTable
If Not con.State = ConnectionState.Open Then
con.Open()
Dim ds As New DataSet()
da.Fill(ds)
gvShape.DataSource = ds
gvShape.DataBind()
End If
da.Fill(dt)
con.Close()
If dt.Rows.Count > 0 Then
gvShape.DataSource = dt
gvShape.DataBind()
Else
dt.Clear()
gvShape.DataSource = dt
gvShape.DataBind()
End If
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Protected Sub gvShape_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvShape.RowDataBound
If e.Row.RowType = DataControlRowType.Header Then
Dim HeaderGrid As GridView = DirectCast(sender, GridView)
Dim HeaderGridRow As New GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert)
Dim HeaderCell As New TableCell()
HeaderCell = New TableCell()
HeaderCell.Text = "SHAPE CATEGORY"
HeaderCell.ColumnSpan = e.Row.Cells.Count
HeaderCell.HorizontalAlign = HorizontalAlign.Center
HeaderGridRow.Cells.Add(HeaderCell)
HeaderGridRow.BackColor = Drawing.Color.DarkBlue
HeaderGridRow.ForeColor = Drawing.Color.White
gvShape.Controls(0).Controls.AddAt(0, HeaderGridRow)
End If
If (e.Row.RowType = DataControlRowType.DataRow) Then
If ((e.Row.RowState = DataControlRowState.Edit) _
OrElse (e.Row.RowState = (DataControlRowState.Edit Or DataControlRowState.Alternate))) Then
e.Row.Attributes.Clear()
Else
Dim cellIndex As Integer = 2
Do While (cellIndex < e.Row.Cells.Count)
Dim _doubleClickButton As LinkButton = CType(e.Row.Cells(0).Controls(0), LinkButton)
Dim _jsDouble As String = ClientScript.GetPostBackClientHyperlink(_doubleClickButton, "")
_jsDouble = _jsDouble.Insert((_jsDouble.Length - 2), cellIndex.ToString)
e.Row.Cells(cellIndex).Attributes("ondblclick") = _jsDouble
cellIndex = (cellIndex + 1)
Loop
End If
End If
End Sub
Protected Sub gvShape_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs) Handles gvShape.SelectedIndexChanging
Dim value As String = gvShape.Rows(e.NewSelectedIndex.ToString()).Cells(1).Text
Label1.Text = value
gvShape.SelectedIndex = e.NewSelectedIndex
Dim id As String = gvShape.Rows(e.NewSelectedIndex).Cells(1).Text
populatedata()
Label2.Text = gvShape.SelectedIndex
End Sub
Protected Sub gvShape_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles gvShape.SelectedIndexChanged
End Sub
Protected Sub gvShape_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gvShape.RowCommand
Dim _gridView As GridView = CType(sender, GridView)
_gridView.EditIndex = -1
Dim _selectedIndex As Integer = Integer.Parse(e.CommandArgument.ToString)
Dim _commandName As String = e.CommandName
Dim _eventArgument As String = Request.Form("__EVENTARGUMENT")
Select Case (_commandName)
Case "DoubleClick"
_gridView.EditIndex = _selectedIndex
_gridView.SelectedIndex = -1
Dim a As String
Dim b As String
Dim c As String
Dim d As String
MsgBox(gvShape.SelectedRow.Cells(1).Text)
Dim CellValue As String = CStr(row("SupplierID"))
End Select
End Sub
Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
For Each r As GridViewRow In gvShape.Rows
If (r.RowType = DataControlRowType.DataRow) Then
Dim cellIndex As Integer = 2
Do While (cellIndex < r.Cells.Count)
Page.ClientScript.RegisterForEventValidation((r.UniqueID + "$ctl00"), cellIndex.ToString)
Page.ClientScript.RegisterForEventValidation((r.UniqueID + "$ctl01"), cellIndex.ToString)
cellIndex = (cellIndex + 1)
Loop
End If
Next
MyBase.Render(writer)
End Sub
Private Sub gvShape_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvShape.RowCreated
For Each control As Control In e.Row.Cells(1).Controls
If TypeOf control Is System.Web.UI.WebControls.Image Then
Dim image As Image = DirectCast(control, System.Web.UI.WebControls.Image)
Dim sql As String
sql = "select CTD_ORDER_ID from V_CAB_TAG_DTLS where CTD_SHAPE_IMG= image "
Dim da As New OracleDataAdapter(sql, con)
Dim dt As New DataTable
If Not con.State = ConnectionState.Open Then
con.Open()
Dim ds As New DataSet()
da.Fill(ds)
gvShape.DataSource = ds
gvShape.DataBind()
End If
da.Fill(dt)
con.Close()
If dt.Rows.Count > 0 Then
gvShape.DataSource = dt
gvShape.DataBind()
Else
dt.Clear()
gvShape.DataSource = dt
gvShape.DataBind()
End If
End If
Next
End Sub
End Class
MY HTMLS CODE IS GIVEN BELOW
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="ShapeInGrid.aspx.vb" Inherits="ShapeInGrid" EnableEventValidation="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div align="center">
<br />
<asp:GridView ID="gvShape" runat="server" AutoGenerateColumns="False" Width ="100 px"
CellPadding="4" Font-Names="calibri" Font-Size="Small" ForeColor="#333333">
<RowStyle BackColor="#EFF3FB" Font-Names="calibri" HorizontalAlign="Left" />
<Columns>
<asp:ButtonField Text="SingleClick" CommandName="SingleClick" Visible="false"/>
<asp:ButtonField Text="DoubleClick" CommandName="DoubleClick" Visible="false"/>
<asp:TemplateField HeaderText="PHOTO">
<ItemTemplate>
<asp:Image ID="Image1" runat="server" Height="50" ImageUrl='<%# "ShapHandler.ashx?ImID=" + Eval("CTD_ORDER_ID") %>'
Width="50" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" BorderStyle="None" />
</asp:GridView>
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<br />
<asp:Label ID="Label2" runat="server" Text="Label"></asp:Label>
</div>
</form>
</body>