Guess you should BindData() in Page_Load only when it is not Postback..
sean12302000 <[EMAIL PROTECTED]> wrote:Hi,
I have a basic datagrid that I wish to make editable, I want to be
able to edit,update and scroll through the records page by page. When
I click the edit button the page just reloads, can someone tell me
what I am missing from my code?
Sean - thanks in advance for your answer
!--- snippet
<script language="vb" runat="server">
Sub Page_Load(sender as Object, e as EventArgs)
BindData()
End Sub
Sub BindData()
Dim myConnection as New SqlConnection
(ConfigurationSettings.AppSettings("connectionString"))
Const strSQL as String = "SELECT listingID, formname,Listeddate
FROM tblListings ORDER BY Listeddate"
Dim myCommand as New SqlCommand(strSQL, myConnection)
Dim myAdapter as New SqlDataAdapter(myCommand)
Dim ds as New DataSet()
myAdapter.Fill(ds)
dgModifyListing.DataSource = ds
dgModifyListing.DataBind()
myConnection.Close()
End Sub
Sub dgModifyListing_Edit(sender As Object, e As
DataGridCommandEventArgs)
Dim intCustomer as Integer = e.Item.Cells(1).Text
dgModifyListing.EditItemIndex =
e.Item.ItemIndex
BindData()
End Sub
Sub dgModifyListing_Update(sender As Object, e As
DataGridCommandEventArgs)
Dim intCustomer as Integer = e.Item.Cells(1).Text
dgModifyListing.EditItemIndex =
e.Item.ItemIndex
BindData()
End Sub
Sub NewPage(sender As Object, e As DataGridPageChangedEventArgs)
dgModifyListing.CurrentPageIndex = e.NewPageIndex
BindData()
End Sub
</script>
<form runat="server">
<asp:DataGrid runat="server" id="dgModifyListing"
BackColor="#eeeeee" Width="85%"
HorizontalAlign="Center"
Font-Name="Verdana"
Font-Size="10pt"
AllowPaging="True"
OnPageIndexChanged="NewPage"
OnEditCommand="dgModifyListing_Edit"
OnUpdateCommand="dgModifyListing_Update">
<HeaderStyle BackColor="Black" ForeColor="White" Font-
Bold="True" HorizontalAlign="Center" />
<AlternatingItemStyle BackColor="White" />
<PagerStyle NextPageText="Next -->" PrevPageText="<--
Prev."
HorizontalAlign="Right" />
<columns>
<asp:EditCommandColumn EditText="Edit Info"
ButtonType="PushButton"
UpdateText="Update"/>
<asp:BoundColumn HeaderText="listingID"
DataField="listingID"/>
<asp:BoundColumn HeaderText="formname"
DataField="formname" />
<asp:BoundColumn HeaderText="formname"
DataField="listeddate" />
</columns>
</asp:datagrid>
</form>
Yahoo! Groups SponsorADVERTISEMENT
---------------------------------
Yahoo! Groups Links
To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
---------------------------------
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
[Non-text portions of this message have been removed]
------------------------ Yahoo! Groups Sponsor --------------------~-->
Make a clean sweep of pop-up ads. Yahoo! Companion Toolbar.
Now with Pop-Up Blocker. Get it for free!
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/saFolB/TM
--------------------------------------------------------------------~->
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/