CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP.NET - InMotion Framework

 How do I get control value in Editable Grid from Click event

Print topic Send  topic

Author Message
cvboucher

Posts: 191
Posted: 10/24/2009, 6:22 PM

I've been using ASP.NET VB for quite a while but am making the switch to InMotion. Please help if you can...

I have a basic editable grid. I added a new column and placed a button in this column. When the user clicks on this button I need to perform some code based on the primary key value of that row. I added a custom code event to the Server On Click event of the button but I don't know how to get the primary key value for that row?

Thanks,
Craig
View profile  Send private message
cvboucher

Posts: 191
Posted: 10/25/2009, 9:49 PM

I figured out how to do this. There may be a better way but this works in case anyone else is trying to accomplish the same thing.

First I create a procedure to assign the primary key value as a command argument to the button.

  
    Private Sub IS_TemplatePages_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles IS_TemplatePages.ItemDataBound  
        If e.Item.ItemType = ListItemType.Item Then  
            Dim row As DataRowView = e.Item.DataItem  
            Dim btnPreview As Button = e.Item.FindControl("btnPreview")  
            btnPreview.CommandName = "Preview"  
            btnPreview.CommandArgument = row("TemplatePageID").ToString()  
        End If  
    End Sub  

Then I added another procedure to perform my code when the Preview Button is clicked.

  
    Private Sub IS_TemplatePages_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles IS_TemplatePages.ItemCommand  
        If e.CommandName = "Preview" Then  
            Dim path As String = ConfigurationManager.AppSettings("ServerPath") + "/innersight_template_pages/" + e.CommandArgument + ".pdf.resources"  
            Dim file As New System.IO.FileInfo(path)  
            Dim fn As String = System.IO.Path.GetFileName(path)  
            If (file.Exists) Then  
                Response.Clear()  
                Response.AddHeader("Content-Disposition", "attachment; filename=" + fn.Replace(".resources", ""))  
                Response.AddHeader("Content-Length", file.Length.ToString())  
                Response.ContentType = "application/pdf"  
                Response.WriteFile(file.FullName)  
                Response.End()  
            Else  
                IS_TemplatePages.Errors.Add("This file you requested, " + fn + ", does not exist.")  
            End If  
        End If  
    End Sub  

Both of these procedures where just inserted between other procedures. I didn't use any object events to place the code.

Now I have another question but I'll post that in another thread.

Thanks,
Craig
View profile  Send private message
peterr


Posts: 5971
Posted: 10/26/2009, 2:50 PM

Hi Craig,

Another way could be to add a hidden field/control to your grid row and bind it to the primary key of your table. Later you should be able to access that value within the server "On Click" event using the following syntax:
((MTButton)sender).Parent.FindControl("<Hidden control name>")

_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Internet Database

Visually create Web enabled database applications in minutes.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.