I need help getting my events set up correctly. Here's what's going on.
I have a project where I don't know the number or location of GridViews until the user selects some options. I need to do this all on one asp page.
I have figured out that I can create and populate a GridView dynamically and add it to a placeholder's controls.
<asp:PlaceHolder ID="phTimeEntryDay" runat="server"></asp:PlaceHolder>
Protected WithEvents gvTimeEntry As GridView = New GridView()
phTimeEntryDay.Controls.Add(gvTimeEntry)
I have added the edit and delete commands using code:
Dim cColumn As New CommandField
cColumn.ButtonType = ButtonType.Link
cColumn.CancelText = "Cancel"
cColumn.UpdateText = "Update"
cColumn.EditText = "Edit"
cColumn.DeleteText = "Delete"
cColumn.ShowEditButton = True
cColumn.ShowDeleteButton = True
cColumn.ShowCancelButton = True
gvTimeEntry.Columns.Add(cColumn)
This does set up the correct postback javascript events, but nothing happens when I click the links and the page is posted back.
In another project where I created the gridview at design-time, I can't find any code created to handle the events that I can copy to my project that does everything at run-time.
<asp:GridView ID="GridViewTimeSheet" runat="server" AllowSorting="True" AutoGenerateColumns="False"
DataKeyNames="EmpPerNo,FromDate,ToDate,EntrySequence" DataSourceID="SqlDataSourcetimeEntry"
ShowFooter="True" EmptyDataText="No Data Available.">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
...
The only complete example I've found uses DataGrid in C# instead of GridView and there are enough differences in DataGrid and GridView that I can't adapt it completely.
Examples in VB or C# are fine if you have some.
Any help would be greatly appreciated.
Thanks,
Bryan Lee