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. Image for the cookie policy date

ImageButton as template column postback problem

Hi, I have a templated column with item template as imagebutton in each row and when i click button, it should fire the event on the page where i redirect to other page. My problem is that event is not fired when i click the button. I bind datagrid in the page load. If i bind grid in !IsPostback than it doesnt render the grid

15 Replies

AD Administrator Syncfusion Team October 24, 2005 01:53 PM UTC

Hi Mac 1. Take a look at the PortfolioGrid sample which includes a Hyperlink column. Also look at the How to create a Hyperlink Column in the Task Based Help section of the Essential Grid for ASP.NET Users Guide which should help you set up the ImageButton Column. 2. Refer to the Using GridGroupingControl section in the Introducing Essential Grouping Grid for ASP.NET: To data bind the Grid control users need to specify the appropriate DataSource and call DataBind() in the Web Form''s Page_Init() event. This is important as Init is the first step in the page''s life cycle and occurs when the page is initialized. Calling DataBind in Page_Load could result in unexpected behavior. Regards Arun


MA Mac October 25, 2005 02:22 AM UTC

Arun, Thanks for the reply. I want to elobrate couple of points here 1. I tried hyperlink as in example and it works fine. 2. I tried image button, but the event hooked up to image button doesnt fire on postback. I tried that with putting my databind code in page_init. Though in ideal situation i wont be able to put the databind in init as the datagrid would be rendered in the button click event. The user will give search criteria and hit submit button which will render the datagrid. The datagrid will have a template column with imagebutton that will render based on the column value. Can you please post or send me an example with your grid component with image button. I will appreciate it. test // Code behined protected void NavigateToInsert(object sender, System.Web.UI.ImageClickEventArgs e) { Response.Redirect("~\\abc.aspx"); } >Hi Mac > >1. Take a look at the PortfolioGrid sample which includes a Hyperlink column. Also look at the How to create a Hyperlink Column in the Task Based Help section of the Essential Grid for ASP.NET Users Guide which should help you set up the ImageButton Column. > >2. Refer to the Using GridGroupingControl section in the Introducing Essential Grouping Grid for ASP.NET: > >To data bind the Grid control users need to specify the appropriate DataSource and call DataBind() in the Web Form''s Page_Init() event. This is important as Init is the first step in the page''s life cycle and occurs when the page is initialized. Calling DataBind in Page_Load could result in unexpected behavior. > >Regards >Arun > >


AD Administrator Syncfusion Team October 25, 2005 08:14 PM UTC

Hi Mac, 1. Here is a sample that uses a Button in the template column. You can unzip it to the ../SyncfusionInstallDir/Web/Grid.Grouping.Web/Samples/1.1/Hierarchies/MasterDetailButtonSelect/CS/ folder or modify the .webinfo file and create an appropriate application directory in IIS and then try building and running it. It is deployed here. 2. Have you taken a look at the Alphabetical sample, which illustrates setting up Alphabetical-Paging logic using the grouping engine''s Summaries and Filters feature. You could use the Grouping Engine''s Filters to restrict the data being displayed in the Grid. Hope this points you in the right direction to do what you are seeking. If you are still having problems, kindly post a sample that we can unzip to Essential Grid samples folder and we will take a look. Regards Arun


MA Mac October 26, 2005 02:56 AM UTC

Arun, Attached is the file. It contains very simple code and requirement. I need a imagebutton as templated column which should postback on the form. When i postback from button, i get following error Server Error in ''/NSTApplications'' Application. -------------------------------------------------------------------------------- Multiple controls with the same ID ''grd1~TR~0~_TOPGROUP_+'' were found. FindControl requires that controls have unique IDs. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Web.HttpException: Multiple controls with the same ID ''grd1~TR~0~_TOPGROUP_+'' were found. FindControl requires that controls have unique IDs. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [HttpException (0x80004005): Multiple controls with the same ID ''grd1~TR~0~_TOPGROUP_+'' were found. FindControl requires that controls have unique IDs.] System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +134 System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +203 System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +203 System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +203 System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +203 System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +203 System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls) +203 System.Web.UI.Control.FindControl(String id, Int32 pathOffset) +164 System.Web.UI.Control.FindControl(String id) +9 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +205 System.Web.UI.Page.ProcessRequestMain() +642 -------------------------------------------------------------------------------- Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032 >Hi Mac, > >1. Here is a sample that uses a Button in the template column. You can unzip it to the ../SyncfusionInstallDir/Web/Grid.Grouping.Web/Samples/1.1/Hierarchies/MasterDetailButtonSelect/CS/ folder or modify the .webinfo file and create an appropriate application directory in IIS and then try building and running it. It is deployed here. > >2. Have you taken a look at the Alphabetical sample, which illustrates setting up Alphabetical-Paging logic using the grouping engine''s Summaries and Filters feature. You could use the Grouping Engine''s Filters to restrict the data being displayed in the Grid. > >Hope this points you in the right direction to do what you are seeking. If you are still having problems, kindly post a sample that we can unzip to Essential Grid samples folder and we will take a look. > >Regards >Arun >

TEST5.zip


AD Administrator Syncfusion Team October 26, 2005 08:06 PM UTC

Hi Mac It looks like you or someone else working with you is working with Praveen from the Essential Grid for ASP.NET team on this issue. Regards Arun


TN Toan Nguyen October 13, 2006 12:59 PM UTC

I ran into the same question. Do you have a solution posted somewhere or it is not doable?

Thanks.
Toan Nguyen


TN Toan Nguyen October 13, 2006 12:59 PM UTC

I ran into the same question. Do you have a solution posted somewhere or it is not doable?

Thanks.
Toan Nguyen


TN Toan Nguyen October 13, 2006 12:59 PM UTC

I ran into the same question. Do you have a solution posted somewhere or it is not doable?

Thanks.
Toan Nguyen


TN Toan Nguyen October 13, 2006 01:00 PM UTC

I ran into the same question. Do you have a solution posted somewhere or it is not doable?

Thanks.
Toan Nguyen

>Hi Mac
>
>It looks like you or someone else working with you is working with Praveen from the Essential Grid for ASP.NET team on this issue.
>
>Regards
>Arun
>
>
>
>


TN Toan Nguyen October 13, 2006 01:06 PM UTC

I ran into the same question. Do you have a solution posted somewhere or it is not doable?

Thanks.
Toan Nguyen

>Hi Mac
>
>It looks like you or someone else working with you is working with Praveen from the Essential Grid for ASP.NET team on this issue.
>
>Regards
>Arun
>
>
>
>


TN Toan Nguyen October 13, 2006 01:15 PM UTC

I ran into the same question. Do you have a solution posted somewhere or it is not doable?

Thanks.
Toan Nguyen

>Hi Mac
>
>It looks like you or someone else working with you is working with Praveen from the Essential Grid for ASP.NET team on this issue.
>
>Regards
>Arun
>
>
>
>


TN Toan Nguyen October 13, 2006 01:15 PM UTC

I ran into the same question. Do you have a solution posted somewhere or it is not doable?

Thanks.
Toan Nguyen

>Hi Mac
>
>It looks like you or someone else working with you is working with Praveen from the Essential Grid for ASP.NET team on this issue.
>
>Regards
>Arun
>
>
>
>


TN Toan Nguyen October 13, 2006 01:19 PM UTC

I ran into the same question. Do you have a solution posted somewhere or it is not doable?

Thanks.
Toan Nguyen

>Hi Mac
>
>It looks like you or someone else working with you is working with Praveen from the Essential Grid for ASP.NET team on this issue.
>
>Regards
>Arun
>
>
>
>


TN Toan Nguyen October 13, 2006 01:19 PM UTC

I ran into the same question. Do you have a solution posted somewhere or it is not doable?

Thanks.
Toan Nguyen

>Hi Mac
>
>It looks like you or someone else working with you is working with Praveen from the Essential Grid for ASP.NET team on this issue.
>
>Regards
>Arun
>
>
>
>


AD Administrator Syncfusion Team October 14, 2006 09:17 AM UTC

Hi Toan,

As mentioned in our Users Guide, Essential Grid expects the data source to include a primary key column. Make sure to include a PrimaryKeyColumn to the TableDescriptor before calling DataBind(), as shown below.

Here is an example of how the WebPage's Init would typically look in an Application using the GridControl.


[C#]

private void Page_Init(object sender, System.EventArgs e)

{
//Add a primary key to the PrimaryKeyColumns collection

GridTableDescriptor mainTD = this.GridGroupingControl.TableDescriptor;

// CustomerID could be a field name in the datasource

mainTD.PrimaryKeyColumns.Add("CustomerID");

//Call DataBind

this.GridGroupingControl.DataBind();

}


Thanks,
A.Sivakumar

Loader.
Live Chat Icon For mobile
Up arrow icon