Hi,
I got image buttons on radgrids along with other data in the coloumns so when click on the image button i want it to pass a certain coloumn field in the form so i can use if statement call a function. I renamed it as outsource but it is not calling the commandName at all
rowInd = e.Item.ItemIndex
comdName = e.CommandName
If comdName = "Outsource" Then
MsgBox("done")
End If
Is there a way to determine whats clicked on the radgrid button like i explained above?
Thanks
I got image buttons on radgrids along with other data in the coloumns so when click on the image button i want it to pass a certain coloumn field in the form so i can use if statement call a function. I renamed it as outsource but it is not calling the commandName at all
rowInd = e.Item.ItemIndex
comdName = e.CommandName
If comdName = "Outsource" Then
MsgBox("done")
End If
Is there a way to determine whats clicked on the radgrid button like i explained above?
Thanks
5 Answers, 1 is accepted
0

Shinu
Top achievements
Rank 2
answered on 05 Feb 2009, 04:23 AM
Hi GarryP,
I hope you are trying to access value from a GridBoundColumn on clicking an ImageButton in a GridButtonColumn. Here is the code snippet for the required scenario.
ASPX:
CS:
Thanks
Shinu
I hope you are trying to access value from a GridBoundColumn on clicking an ImageButton in a GridButtonColumn. Here is the code snippet for the required scenario.
ASPX:
<telerik:GridBoundColumn DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" UniqueName="ProductName"> |
</telerik:GridBoundColumn> |
<telerik:GridButtonColumn ButtonType="imagebutton" CommandName="Outsource" ImageUrl="~/Images/Image1.gif" ></telerik:GridButtonColumn> |
CS:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) |
{ |
if (e.CommandName == "Outsource") |
{ |
int rowindex = e.Item.ItemIndex; |
GridDataItem item = (GridDataItem)e.Item; |
string strTxt=item["ProductName"].Text.ToString(); |
} |
} |
Thanks
Shinu
0

GarryP
Top achievements
Rank 1
answered on 05 Feb 2009, 11:23 AM
Hi,
I converted the code to VB.NET and it was giving an error saying "Error 1 'CommandName' is not a member of 'Telerik.WebControls.GridItemEventArgs'."
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridItemEventArgs)
If e.CommandName = "Outsource" Then
Dim rowindex As Integer = e.Item.ItemIndex
Dim item As Telerik.WebControls.GridDataItem = DirectCast(e.Item, Telerik.WebControls.GridDataItem)
Dim strTxt As String = item("ProductName").Text.ToString()
End If
End Sub
where as i used the code below, which was not doing anything.
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles RadGrid1.ItemCommand
Dim rowInd As Integer
Dim comdName As String = ""
rowInd = e.Item.ItemIndex
comdName = e.CommandName
If comdName = "Outsource" Then
MsgBox("done")
End If
End Sub
and that was not giving errors but was not calling at all.
Thanks
I converted the code to VB.NET and it was giving an error saying "Error 1 'CommandName' is not a member of 'Telerik.WebControls.GridItemEventArgs'."
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridItemEventArgs)
If e.CommandName = "Outsource" Then
Dim rowindex As Integer = e.Item.ItemIndex
Dim item As Telerik.WebControls.GridDataItem = DirectCast(e.Item, Telerik.WebControls.GridDataItem)
Dim strTxt As String = item("ProductName").Text.ToString()
End If
End Sub
where as i used the code below, which was not doing anything.
Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.WebControls.GridCommandEventArgs) Handles RadGrid1.ItemCommand
Dim rowInd As Integer
Dim comdName As String = ""
rowInd = e.Item.ItemIndex
comdName = e.CommandName
If comdName = "Outsource" Then
MsgBox("done")
End If
End Sub
and that was not giving errors but was not calling at all.
Thanks
0

Shinu
Top achievements
Rank 2
answered on 06 Feb 2009, 05:18 AM
Hi GarryP,
Have you set the ItemCommand EventHandler in the aspx?
ASPX:
Shinu
Have you set the ItemCommand EventHandler in the aspx?
ASPX:
<telerik:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None" OnItemCommand="RadGrid1_ItemCommand" OnNeedDataSource="RadGrid1_NeedDataSource" > |
Shinu
0

GarryP
Top achievements
Rank 1
answered on 16 Feb 2009, 10:48 AM
Hi.
I have hyperlink buttons, which i added manually as the following code.
<radG:GridTemplateColumn UniqueName="TemplateColumn">
<ItemTemplate>
<a href="javascript:openPopup('WordAndSound.aspx?strCompanyNo=<%# Eval("CompanyNo")%>&strUserNo=<%#Eval("UserNo")%>&strSoundFile=<%#Eval("FileName")%>&strDocFileName<%#Eval("DocFileName")%>&strStatus=<%#Eval("Status")%>')">Play</a>
<a href="javascript:openPopup('WordAndSound.aspx?strCompanyNo=<%# Eval("CompanyNo")%>&strUserNo=<%#Eval("UserNo")%>&strDictNo=<%#Eval("DictNo")%>&strDocFileName=<%#Eval("DocFileName")%>&strStatus=<%#Eval("Status")%>')">View</a>
</ItemTemplate>
</radG:GridTemplateColumn>
The code above passes parameters to the other page page and the code below opens that page as a popup.
<script type="text/javascript" language="javascript">
function openPopup(strOpen)
{
open(strOpen, "Info", "status=1, width=1000, height=700,resizable=1, scrollbars=1");
}
</script>
I need to do the same as what the code above does in vb.net code.
such as if e.commandName = "play" then
I want it to open another pop up aspx page and pass the parameters to that page. I do not want to do redirect but open a new page. Do you know how can this be done?
Thanks
I have hyperlink buttons, which i added manually as the following code.
<radG:GridTemplateColumn UniqueName="TemplateColumn">
<ItemTemplate>
<a href="javascript:openPopup('WordAndSound.aspx?strCompanyNo=<%# Eval("CompanyNo")%>&strUserNo=<%#Eval("UserNo")%>&strSoundFile=<%#Eval("FileName")%>&strDocFileName<%#Eval("DocFileName")%>&strStatus=<%#Eval("Status")%>')">Play</a>
<a href="javascript:openPopup('WordAndSound.aspx?strCompanyNo=<%# Eval("CompanyNo")%>&strUserNo=<%#Eval("UserNo")%>&strDictNo=<%#Eval("DictNo")%>&strDocFileName=<%#Eval("DocFileName")%>&strStatus=<%#Eval("Status")%>')">View</a>
</ItemTemplate>
</radG:GridTemplateColumn>
The code above passes parameters to the other page page and the code below opens that page as a popup.
<script type="text/javascript" language="javascript">
function openPopup(strOpen)
{
open(strOpen, "Info", "status=1, width=1000, height=700,resizable=1, scrollbars=1");
}
</script>
I need to do the same as what the code above does in vb.net code.
such as if e.commandName = "play" then
I want it to open another pop up aspx page and pass the parameters to that page. I do not want to do redirect but open a new page. Do you know how can this be done?
Thanks
0

Shinu
Top achievements
Rank 2
answered on 16 Feb 2009, 11:57 AM
Hi GarryP,
You can check out the following Online demo where a similar scenario is implemented.
Here the Editcolumn is a HyperLinkColumn. A client side function to open a window is called on clicking the Hyperlink and a parameter(EmployeeID) is passed to it.
VB:
Thanks
Shinu
You can check out the following Online demo where a similar scenario is implemented.
Here the Editcolumn is a HyperLinkColumn. A client side function to open a window is called on clicking the Hyperlink and a parameter(EmployeeID) is passed to it.
VB:
Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As GridItemEventArgs) |
If TypeOf e.Item Is GridDataItem Then |
Dim editLink As HyperLink = DirectCast(e.Item.FindControl("EditLink"), HyperLink) |
editLink.Attributes("href") = "#" |
'passing EmployeeID as a parameter |
editLink.Attributes("onclick") = [String].Format("return ShowEditForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("EmployeeID"), e.Item.ItemIndex) |
End If |
End Sub |
Thanks
Shinu