trueneutral
Programmer
I am having problems using a Datagrid
I've followed many tutorials and as far as I can tell I'm doing everything I'm
supposed to.
1. I've created the HTML part of the datagrid (There's a little more to it but
there's no need to add it here):
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Grade"
%>
</ItemTemplate>
<EditItemTemplate>
<asp
ropdownlist runat="server" id="Grade" Text='<%#
DataBinder.Eval(Container.DataItem, "Grade"
%>'/> </EditItemTemplate>
</asp:TemplateColumn>
</Columns>
2. I've created the VB code, and set up the SQL connection to the database:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If IsPostBack = True Then
Else
bindData()
End If
End Sub
Public Sub DataGrid1_edit(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
DataGrid1.EditItemIndex = CInt(e.Item.ItemIndex)
DataGrid1.DataBind()
End Sub
Public Sub DataGrid1_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
DataGrid1.EditItemIndex = -1
End Sub
Here's what happens: The table is set up, the information is put into the table
and the edit button is added onto the begining of each row. But when I press
"Edit" the entire table dissapears! Does anyone know why this happens?
I've followed many tutorials and as far as I can tell I'm doing everything I'm
supposed to.
1. I've created the HTML part of the datagrid (There's a little more to it but
there's no need to add it here):
<Columns>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update"
CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "Grade"
</ItemTemplate>
<EditItemTemplate>
<asp
DataBinder.Eval(Container.DataItem, "Grade"
</asp:TemplateColumn>
</Columns>
2. I've created the VB code, and set up the SQL connection to the database:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
If IsPostBack = True Then
Else
bindData()
End If
End Sub
Public Sub DataGrid1_edit(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
DataGrid1.EditItemIndex = CInt(e.Item.ItemIndex)
DataGrid1.DataBind()
End Sub
Public Sub DataGrid1_Cancel(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
DataGrid1.EditItemIndex = -1
End Sub
Here's what happens: The table is set up, the information is put into the table
and the edit button is added onto the begining of each row. But when I press
"Edit" the entire table dissapears! Does anyone know why this happens?