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

Using grid ItemCommand event when grid is created programmatically

4 Answers 73 Views
Grid
This is a migrated thread and some comments may be shown as answers.
William
Top achievements
Rank 1
William asked on 20 Nov 2008, 08:40 PM
Hi. I was using the ItemCommand event to handle commands on a grid that was created statically. Now that I've changed the grid to be created programmatically, commands from the grid aren't being handled. Does anyone no how I might be able to solve this?

This is part of my code: 

Protected WithEvents EmployeesGrid As RadGrid

Public

 

Sub EmployeesGrid_ItemCommand(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles EmployeesGrid.ItemCommand

 




4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 21 Nov 2008, 05:17 AM
Hi William,

I tried the following code snippet to achieve the desired scenario. Give a try with the following code snippet and  see if it helps.

CS:
 protected void Page_Init(object sender, System.EventArgs e) 
   { 
    RadGrid grid = new RadGrid(); 
    grid.ID = "RadGrid1"
    grid.AutoGenerateColumns = true
    grid.DataSourceID = "SqlDataSource1"
    grid.AllowSorting = true
 
    // Add the ItemCommand event handler 
    grid.ItemCommand += new GridCommandEventHandler(grid_ItemCommand); 
 
    // Add the grid to the placeholder 
    this.PlaceHolder1.Controls.Add(grid); 
 
    
  } 
 
    void grid_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        
    } 

Thanks
Shinu.
0
William
Top achievements
Rank 1
answered on 21 Nov 2008, 06:38 PM
Shinu,

Excellent! it works.

Thanks a lot,

William
0
Shinu
Top achievements
Rank 2
answered on 24 Nov 2008, 05:17 AM
Hi William,

You can also refer the following help document link which explains more on Programmatic creation of RadGrid.
Programmatic creation

Thanks
Shinu
0
William
Top achievements
Rank 1
answered on 24 Nov 2008, 12:39 PM
Shinu,

Great!

Thanks again,

William
Tags
Grid
Asked by
William
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
William
Top achievements
Rank 1
Share this question
or