How to create events for dynamically generated datagrid
-
I don't want to drag and drop datagrid from tools, but I just want to create it during runtime using vb.net syntax on asp.net page using asp.net 1.1 version. ASP.NET 2003. dim dg as datagrid then adding bound column by creating its object. It is fine upto this level. Even it gets implemented. But I couldn't find any article that helps in generating events for RUNTIME GENERATED DATAGRID. So can anybody help in this regard. I would like to implement events like PageIndexChanged, SortCommand, ItemDataBound. So please help in this regard. Balasaheb Software Developer Platform: Asp.net,vb.net Database: SQL Server 2000
-
I don't want to drag and drop datagrid from tools, but I just want to create it during runtime using vb.net syntax on asp.net page using asp.net 1.1 version. ASP.NET 2003. dim dg as datagrid then adding bound column by creating its object. It is fine upto this level. Even it gets implemented. But I couldn't find any article that helps in generating events for RUNTIME GENERATED DATAGRID. So can anybody help in this regard. I would like to implement events like PageIndexChanged, SortCommand, ItemDataBound. So please help in this regard. Balasaheb Software Developer Platform: Asp.net,vb.net Database: SQL Server 2000
I'm using VS.NET 2005, but it should be similar: DataGrid myDataGrid = new DataGrid(); myDataGrid.PageIndexChanged += new DataGridPageChangedEventHandler(myDataGrid_PageIndexChanged); ... protected void myDataGrid_PageIndexChanged(object sender, EventArgs e) { .... }
-
I'm using VS.NET 2005, but it should be similar: DataGrid myDataGrid = new DataGrid(); myDataGrid.PageIndexChanged += new DataGridPageChangedEventHandler(myDataGrid_PageIndexChanged); ... protected void myDataGrid_PageIndexChanged(object sender, EventArgs e) { .... }
Thanks for ur help But ur code doesn't work after converting in vb.net means like this dim dg as new datagrid() dg.pageindexchanged event is not available. Does I need to import some file? Wht should I do now? I think I need to add RaiseEvent as event bcoz when I write dg.pageindexchanged It gives me error saying 'dg.pageindexchanged is a event and cannot be called directly. Use RaiseEvent statement' Can u suggent me on this event?:) Balasaheb Software Developer Platform: Asp.net,vb.net Database: SQL Server 2000 -- modified at 12:37 Friday 23rd June, 2006
-
Thanks for ur help But ur code doesn't work after converting in vb.net means like this dim dg as new datagrid() dg.pageindexchanged event is not available. Does I need to import some file? Wht should I do now? I think I need to add RaiseEvent as event bcoz when I write dg.pageindexchanged It gives me error saying 'dg.pageindexchanged is a event and cannot be called directly. Use RaiseEvent statement' Can u suggent me on this event?:) Balasaheb Software Developer Platform: Asp.net,vb.net Database: SQL Server 2000 -- modified at 12:37 Friday 23rd June, 2006
Sorry, I didn't notice you are using vb. I don't know exact syntax for handling events in vb, but this is what I found on msdn:[^] '---------------------------------------------- Visual Basic (Usage) Dim instance As DataGrid Dim handler As DataGridPageChangedEventHandler AddHandler instance.PageIndexChanged, handler '---------------------------------------------- This code is not supposed to raise event, but assign event handler to event. Event is raised automaticly when you change page of datagrid by clicking it. I hope it helps -- modified at 8:44 Sunday 25th June, 2006