Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

My datagrid is dissapearing!

Status
Not open for further replies.

trueneutral

Programmer
Sep 15, 2003
13
CA
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=&quot;LinkButton&quot; UpdateText=&quot;Update&quot;
CancelText=&quot;Cancel&quot; EditText=&quot;Edit&quot;></asp:EditCommandColumn>

<asp:TemplateColumn>
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, &quot;Grade&quot;) %>
</ItemTemplate>
<EditItemTemplate>
<asp:Dropdownlist runat=&quot;server&quot; id=&quot;Grade&quot; Text='<%#
DataBinder.Eval(Container.DataItem, &quot;Grade&quot;) %>'/> </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
&quot;Edit&quot; the entire table dissapears! Does anyone know why this happens?
 
I fixed this now. Basically the thing I keep forgetting to do no matter how many times I use datagrids is that I forget to bind my using postback properly. Like this:

If IsPostBack = True Then
Else
bindData()
End If

You can find a lot of issues I've tackled at this thread here:

or you can go to my personal homepage where I've written an article dealing with datagrids:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top