We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Buttun in a GGC

Thread ID:

Created:

Updated:

Platform:

Replies:

45558 Jun 23,2006 04:48 AM Jun 30,2006 05:45 AM ASP.NET Web Forms (Classic) 9
loading
Tags: GridGroupingControl
Chris
Asked On June 23, 2006 04:48 AM

Dear all, i''ve put an ASP button in a template column (since i didn''t manage to use the celltype of the grid ...). I want to use this button to do a action on the actual record using the primary key. How can I catch : - the event raised by this button ? - the row of the actual button ? Thanks in advance, Chris

Ramu [Syncfusion]
Replied On June 23, 2006 03:56 PM

Hi Chris, You can catch an event raised by defining the OnClick event handler for the button inside the template in the aspx and you can retreive the row and its record inside this event as shown in the below code. Here is the code snippet to catch the event raised by the button. In the aspx page: [aspx] [C#] protected void btnSubmit_Click(object sender, EventArgs e) { Button btn=(Button )sender; //To get the current row. GridRow row = (GridRow)btn.Parent.Parent; //To Retrive the current record of rhe row. Record rd = row.Record; //To retrive the primary key of the record. string str = rd.GetValue("CategoryID").ToString(); this.TextBox1.Text = str.ToString(); } Steps to create the sample: Step1: Added an ''UnboundColumn'' and and named it as “Submit” Step2: Right click the grid to edit the grid in template mode. Add the button to the item template of the “Submit” column in the grid. Step3: Define the onclick event for the Button. Step4: Get the primary key as illustrated in the ''btnSubmit_Click'' method. Please let us know if you have any further questions. Thanks, Ramu.K ButtonInTemplate

Ramu [Syncfusion]
Replied On June 23, 2006 04:23 PM

Hi Chris, The aspx code is not seen in the above post so I have replaced the “<” symbol with “$” symbol for you to have a look in this browser. Here is the aspx code. [aspx] $sfwg:GridColumnDescriptor Name="Submit"> $ItemTemplate> $asp:Button ID="btnSubmit" runat="server" Text="submit" OnClick="btnSubmit_Click" /> $/ItemTemplate> $/sfwg:GridColumnDescriptor> Thanks, Ramu.K

Chris
Replied On June 26, 2006 04:14 AM

Dear Ramu, thanks for your answer but the event isn''t fired... I use visual basic with the framework 1.1, may be this information will help. I defined my proc like that: Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) without defining the handler... I suppose it is created by the grid control ? Any more idea ? Chris

Administrator [Syncfusion]
Replied On June 26, 2006 11:58 AM

I''ve just found my event problem. Because of another part of code, the oninit proc was never called ! But now, I''ve problems with the record object in the btnSubmit_Click proc... I cannot access to the properties of the record. I have to use the cell object instead but I am not to sure if I can use it on hidden cells... Thanks for the help ! Chris >Dear Ramu, > >thanks for your answer but the event isn''t fired... >I use visual basic with the framework 1.1, may be this information will help. >I defined my proc like that: >Protected Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) >without defining the handler... I suppose it is created by the grid control ? > >Any more idea ? > >Chris

Ramu [Syncfusion]
Replied On June 26, 2006 02:17 PM

Hi Chris, I am not sure. I understand, Are you saying that you are not able to access the rd.GetValue("CategoryID") record value from the grid inside this btn_Submit Event ?. where rd is the object of the Record for the row in which the button is present. Could you explain me where exactly you get the problem in accessing the record? So that we could get your problem solved as soon has possible. Also I have attached the vb sample in framework 1.1. Are you facing similar issue in this sample? You will have to update the .webinfo file based on where you install the sample, before you can run the project. Remember to mark the folder as an application in IIS before you open the project. ButtonInTemplate_vb_1.1 Thanks, Ramu.K

Chris
Replied On June 27, 2006 05:53 AM

Hi, this is exactly my problem ! I suppose this is due to the different datasources between you and me: I have a dataset with 2 datatables and 1 datarelation. Your example works perfectly.

Chris
Replied On June 27, 2006 10:47 AM

Since i have to use the cell object to access my primary key but i don''t want to see if, is there a way to mask a column with setting the property width to 0 ?

Ramu [Syncfusion]
Replied On June 27, 2006 08:17 PM

Hi Chris, I have created the sample with two tables Categories, Products joined by CategoryID field from the NWIND database. Please have a look at the attached sample. ButtonInTemplate_With_Relation The primary key column (ProductID) is not visible in grid. This is achieved by removing the specified column from the ''VisibleColumns'' collections. If this doesn’t solves the problem. Could you provide me the code snippet demonstrating the issue so that we could exactly get your problem be resolved. Thanks for your practice. Thanks, Ramu.K

Administrator [Syncfusion]
Replied On June 30, 2006 05:45 AM

Dear Ramu, thanks, it works fine ! The problem I had was just that I cannot access the object when debugging... When the code is executed, it works ! Thanks a lot, Chris >Hi Chris, > >I have created the sample with two tables Categories, Products joined by CategoryID field from the NWIND database. Please have a look at the attached sample. > >ButtonInTemplate_With_Relation > >The primary key column (ProductID) is not visible in grid. This is achieved by removing the specified column from the ''VisibleColumns'' collections. > >If this doesn’t solves the problem. Could you provide me the code snippet demonstrating the issue so that we could exactly get your problem be resolved. > >Thanks for your practice. > >Thanks, >Ramu.K

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;