This is a migrated thread and some comments may be shown as answers.

Radgrid_Itemcommand Problem

1 Answer 41 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Sharyu Desai
Top achievements
Rank 1
Sharyu Desai asked on 18 Jun 2010, 06:13 AM
I use Radgrid which contain template columns. In template column i use item Template With ASP:Imagebutton & ASP:label.
When i click on first image button then RadGrid_Itemcommand Is fired. After that i click on second image button is also fine. But after that when i again click on first image button then item_Command not fired.
Please give me solution it's very urgent. Thanks in advance.
I Post my code.
ProductCatalog.aspx

<%

@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="ProductCatalog.aspx.vb" Inherits="ProductCatalog" EnableViewStateMac="false" %>

 

 <%

@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

 

 <%

@ Register Src="ProductDetails(vb).ascx" TagName="ProductDetails" TagPrefix="uc1" %>

 

 

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">

 

 

<html xmlns="http://www.w3.org/1999/xhtml">

 

     

<head></head>

 

     

<body>

 

         

<asp:UpdatePanel ID="updatepanel2" runat="server" UpdateMode="Conditional" >

 

 

            <ContentTemplate>

 

 

            <script type="text/javascript">

 

 

             

 function CloseActiveToolTip() {

 

 

            setTimeout(

 

            function() {

 

            var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();

 

 

             

if (tooltip) tooltip.hide();

 

 

             }, 1000);

        }

         

</script>

 

 

 

 

 

<telerik:RadToolTipManager runat="server" ID="RadToolTipManager1" Position= "Center" BorderWidth="1px" RelativeTo= "Element" Width="500px" Height="300px" HideEvent="FromCode" Skin="WebBlue" ShowEvent="OnClick" VisibleOnPageLoad="true" Modal="true" OnAjaxUpdate="OnAjaxUpdate" BackColor="#EEEEEE" Animation= "Fade" >

 

 

</telerik:RadToolTipManager>

 

 

<telerik:RadSplitter ID="RadSplitter1" Runat="server" Width="1015px" Height="886px" BackColor="Black" Skin="WebBlue" >

 

 

<telerik:RadPane id="Radpane1" runat="server" width="22px" Collapsed="false" scrolling="None" minwidth="22" CssClass="Radpane" BackColor="#EEEEEE" Height="16px"><telerik:RadSlidingZone ID="SlidingZone1" runat="server" BackColor="#EEEEEE" clicktoopen="true" Visible="true" width="22" DockedPaneId="Contacts" >

 

 

<telerik:RadSlidingPane ID="Contacts" runat="server" Visible="true" width="190px" Height="400px" >

 

 

<telerik:RadTreeView ID="RadTreeView1" runat="server" BackColor="Black" Font-Names="Tahoma" Font-Size="13px" Skin="Hay" Height="900px" Width="175px" ForeColor="White"></telerik:RadTreeView></telerik:RadSlidingPane></telerik:RadSlidingZone></telerik:RadPane>

 

 

<telerik:RadSplitBar id="RadSplitbar1" runat="server" CollapseMode="Forward" BackColor="#EEEEEE"></telerik:RadSplitBar>

 

 

<telerik:RadPane id="RadPane2" runat="server" scrolling="y" style="z-index: 1; left: 1px; top: 329px; position: absolute; height: 653px; width: 856px"><table cellpadding="0" cellspacing="0" ><tr><td>

 

 

<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" BackColor="Black" Font-Names="Verdana" Font-Size="Medium" ForeColor="#800040" GridLines="None" Height="624px" Skin="Black" style="margin-bottom: 0px; margin-top: 0px;" Visible="False" Width="990px" OnItemCommand="radgrid1_itemcommand" >

 

 

<headercontextmenu enabletheming="true"><collapseanimation duration="200" type="OutQuint" />

 

 

</headercontextmenu><mastertableview DataKeyNames="srno"><rowindicatorcolumn><HeaderStyle Width="20px" /></rowindicatorcolumn>

 

 

<expandcollapsecolumn><HeaderStyle Width="20px" /></expandcollapsecolumn>

 

 

<Columns>

 

 

<telerik:GridTemplateColumn HeaderStyle-HorizontalAlign="Center" HeaderStyle-Width="10px" HeaderText="" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="100px" UniqueName="TemplateColumn" >

 

 

<ItemTemplate>

 

 

<asp:ImageButton ID="Image1" Runat="server" CommandName="Image1" Height="130px" ImageAlign="Middle" ImageUrl='<%#""& Container.DataItem("imag1")&"" %>' Width="140px" AlternateText='<%#""& Container.DataItem("style1")&"" %>' />

 

 

<asp:Label ID="label1" runat="server" Font-Names="Tahoma" Font-Size="13px" ForeColor="White" Width="140px" Text='<%#""& Container.DataItem("style1")&"" %>' />

 

 

</ItemTemplate>

 

 

    <HeaderStyle Width="10px" /><ItemStyle Width="100px" />

 

 

    </telerik:GridTemplateColumn>

 

 

    <telerik:GridTemplateColumn HeaderStyle-Width="10px" HeaderText="" ItemStyle-Width="100px"     UniqueName="TemplateColumn"     ItemStyle-HorizontalAlign="Center" >

 

 

<ItemTemplate>

 

 

<asp:ImageButton ID="Image2" Runat="server" AlternateText='<%#""& Container.DataItem("style2")&"" %>' BorderColor="#eeeeee" BorderWidth="0px" CommandName="Image2" Height="130px" ImageAlign="Middle" ImageUrl='<%#""& Container.DataItem("imag2")&"" %>' Width="140px" />

 

 

<asp:Label ID="label2" runat="server" ForeColor="White" Font-Names="Tahoma" Font-Size="13px" Width="140px" Text='<%#""& Container.DataItem("style2")&"" %>' />

 

 

</ItemTemplate><HeaderStyle Width="10px" /><ItemStyle Width="100px" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderStyle-Font-Bold="true" HeaderStyle-ForeColor="Aqua" HeaderStyle-Font-Names="Tahoma" HeaderStyle-Font-Size="15px" HeaderText="Product Catalog" ItemStyle-Width="100Px" UniqueName="TemplateColumn" ItemStyle-HorizontalAlign="Center">

 

 

<ItemTemplate>

 

 

<asp:ImageButton ID="Image3" Runat="server" AlternateText='<%#""& Container.DataItem("style3")&"" %>' BorderColor="#eeeeee" BorderWidth="0px" CommandName="Image3" Height="130px" ImageAlign="Middle" ImageUrl='<%#""& Container.DataItem("imag3")&"" %>' Width="140px" />

 

 

<asp:Label ID="label3" runat="server" ForeColor="White" Font-Names="Tahoma" Font-Size="13px" Width="140px" Text='<%#""& Container.DataItem("style3")&"" %>' />

 

 

</ItemTemplate><HeaderStyle Font-Bold="True" /><ItemStyle Width="100px" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="" ItemStyle-Width="100Px" UniqueName="TemplateColumn" ItemStyle-HorizontalAlign="Center">

 

 

<ItemTemplate>

 

 

<asp:ImageButton ID="Image4" Runat="server" AlternateText='<%#""& Container.DataItem("style4")&"" %>' BorderColor="#eeeeee" BorderWidth="0px" CommandName="Image4" Height="130px" ImageAlign="Middle" ImageUrl='<%#""& Container.DataItem("imag4")&"" %>' Width="140px" />

 

 

<asp:Label ID="label4" runat="server" ForeColor="White" Font-Names="Tahoma" Font-Size="13px" Width="140px" Text='<%#""& Container.DataItem("style4")&"" %>' />

 

 

</ItemTemplate><ItemStyle Width="100px" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="" ItemStyle-Width="100Px" UniqueName="TemplateColumn" ItemStyle-HorizontalAlign="Center">

 

 

<ItemTemplate>

 

 

<asp:ImageButton ID="Image5" Runat="server" AlternateText='<%#""& Container.DataItem("style5")&"" %>' BorderColor="#eeeeee" BorderWidth="0px" CommandName="Image5" Height="130px" ImageAlign="Middle" ImageUrl='<%#""& Container.DataItem("imag5")&"" %>' Width="140px" />

 

 

<asp:Label ID="label5" runat="server" ForeColor="White" Font-Names="Tahoma" Font-Size="13px" Width="140px" Text='<%#""& Container.DataItem("style5")&"" %>' />

 

 

</ItemTemplate><ItemStyle Width="100px" />

 

 

</telerik:GridTemplateColumn>

 

 

<telerik:GridTemplateColumn HeaderText="" ItemStyle-Width="100Px" UniqueName="TemplateColumn" ItemStyle-HorizontalAlign="Center">

 

 

<ItemTemplate>

 

 

<asp:ImageButton ID="Image6" Runat="server" AlternateText='<%#""& Container.DataItem("style6")&"" %>' BorderColor="#eeeeee" BorderWidth="0px" CommandName="Image5" Height="130px" ImageAlign="Middle" ImageUrl='<%#""& Container.DataItem("imag6")&"" %>' Width="140px" />

 

 

<asp:Label ID="label6" runat="server" ForeColor="White" Font-Names="Tahoma" Font-Size="13px" Width="140px" Text='<%#""& Container.DataItem("style6")&"" %>' />

 

 

</ItemTemplate><ItemStyle Width="100px" />

 

 

</telerik:GridTemplateColumn>

 

 

</Columns>

 

 

</mastertableview>

 

 

<clientsettings enablepostbackonrowclick="true">

 

 

<selecting allowrowselect="true" />

 

 

</clientsettings><HeaderStyle Height="1px" />

 

 

<filtermenu enabletheming="True"><collapseanimation duration="200" type="OutQuint" /></filtermenu>

 

 

</telerik:RadGrid></td></tr></tr></table></telerik:RadPane>

 

 

</telerik:RadSplitter>

 

 

</div>

 

 

</ContentTemplate>

 

 

</asp:UpdatePanel>

 

 <

asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePanel2" >

 

 

<ProgressTemplate>

 

 

<div id="OuterTableCellOverlay">

 

 

<div id="InnerTableCellOverlay" style="color:Blue" ><B>... LOADING PLEASE WAIT...</B>&nbsp;<BR />

 

 

<asp:Image id="LoadImage1" runat="server" ImageUrl="~/Images/ajax-loader.gif"></asp:Image>

 

 

</div>

 

 

</div>

 

 

</ProgressTemplate>

 

 

</asp:UpdateProgress>

 

 </

 

body>

 

 </

 

html>

 

 

</asp:Content>

 

 

 


ProductCatalog.aspx.vb

 

 

 Imports

 

System.Data

 

 

Imports System.Data.SqlClient

 

 

Imports System.Data.Sql

 

 

Imports System.Web.UI

 

 

 Imports Telerik.Web.UI

 

 

 Imports ASP

 

 

 Imports cls1

 

 

 Imports Microsoft.Vbe.Interop

 

 

 Imports Telerik.Web

 

 

Imports  System

 

 

 Imports System.Configuration

 

 

Imports System.Collections

 

 

Imports System.Web

 

 

Imports System.Web.Security

 

 

Imports  System.Web.UI.WebControls

 

 

Imports System.Web.UI.WebControls.WebParts

 

 

Imports System.Web.UI.HtmlControls

 

 

 

 

Partial

 

Class ProductCatalog

 

 

Inherits System.Web.UI.Page

 

 

 

Dim db As clsDBLayer

 

 

Dim temp As Telerik.Web.UI.RadTreeNode

 

Dim temp1 As Telerik.Web.UI.RadTreeNode

 

Dim newvalue As String

 

Dim dsfillgrid As New DataSet

 

Dim getgroupid As Integer

 

Dim dt As DataTable

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

 

'If userid=null then goto login page

 

If Session("Userid") = "" Then

 

Response.Redirect("Login.aspx", False)

 

 

End If

 

 

filltreeview()
End Sub

 

 

 

 

 

'this function used to fill the grid with style

 

 

 

 

Protected Sub RadTreeView1_NodeClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadTreeNodeEventArgs) Handles RadTreeView1.NodeClick

 

 

 

Dim str1 As String

 

 

Try

 

 

' if the clicked node is last child Node then checked

 

 

 

 

If e.Node.Nodes.Count = 0 Then

 

 

RadGrid1.Visible =

True

 

 

str1 = RadTreeView1.SelectedValue

 

Session(

"LastGroup") = RadTreeView1.SelectedValue

 

 getgroupid = CommonFunction.UDGetSingleValue(

"select groupid from groupmaster where name='" & str1 & "'", True,clsStartUp.Conjewel)

 

 

db = New clsDBLayer

 

 dsfillgrid = db.GetDataset(

"SET QUOTED_IDENTIFIER OFF ; Exec PROC_Teststylegridmatrix " & getgroupid & " SET QUOTED_IDENTIFIER on", "Grid")

 

 

Session(

"Fillgrid") = dsfillgrid

 

 RadGrid1.DataSource = dsfillgrid.Tables(

"Grid")

 

 RadGrid1.DataBind()

 

Me.RadToolTipManager1.Visible = False

 

 

Else

 

 

RadGrid1.Columns.Clear()

 

RadGrid1.Controls.Clear()

RadGrid1.Visible =

False

 

 

End If

 

 

 

 

 

Catch ex As Exception

 

 

End Try

 

 

 

 

End Sub

 

 

 

'This function used to display the tooltip when we click on image(Style)

 

 

 

Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand

 

 

Dim ColNo As String = Right(e.CommandName, 1)

 

 

Dim image As Control = e.Item.FindControl("Image" & ColNo)

 

 

Dim currentRow As ImageButton = DirectCast(e.CommandSource, ImageButton)

 

 

Try

 

 

'When clicked on image show tooltip with selected item

 

 

Me.RadToolTipManager1.Visible = True

 

 

 

clsStartUp.GridEdit =

False

 

 

 

clsStartUp.vieworder =

False '21nov

 

 

clsStartUp.submitorder = False '21nov

 

 

clsStartUp.imagepath = currentRow.ImageUrl

 

Session(

"imagename") = currentRow.AlternateText

 

 

 

If LTrim(Session("imagename")) <> "" Then

 

 

Session("styleid") = CommonFunction.UDGetSingleValue("select styleid from stylemaster where name='" & Session("imagename") & "'", True, clsStartUp.Conjewel)

 

 

Me.RadToolTipManager1.TargetControls.Add(image.ClientID, currentRow.ID, True)

 

 

 

Dim ctrl As Control = Page.LoadControl("ProductDetails(vb).ascx")

 

 

End If

 

 

If LTrim(Session("imagename")) = "" Then

 

 

Me.RadToolTipManager1.Visible = False

 

 

End If

 

 

Catch ex As Exception

 

 

 

 

End Try

 

 

End Sub

 

 

 

 

Protected Sub OnAjaxUpdate(ByVal sender As Object, ByVal args As ToolTipUpdateEventArgs)

 

Me.UpdateToolTip(args.Value, args.UpdatePanel)

 

 

End Sub

 

 

 

 

Private Sub UpdateToolTip(ByVal elementID As String, ByVal panel As UpdatePanel)

 

Dim ctrl As Control = Page.LoadControl("ProductDetails(vb).ascx")

 

panel.ContentTemplateContainer.Controls.Add(ctrl)

 

End Sub

 

 

 

End

 

Class

 

 

 

1 Answer, 1 is accepted

Sort by
0
Veli
Telerik team
answered on 23 Jun 2010, 01:33 PM
Hi Sharyu,

I see you are using RadGrid with simple databinding (calling DataBind()). Item commands in RadGrid require that RadGrid is databound using the NeedDataSource event or declarative data sources. Consider changing the databinding mechanism of the grid.

Greetings,
Veli
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Sharyu Desai
Top achievements
Rank 1
Answers by
Veli
Telerik team
Share this question
or