Sub Page_Load(sender as Object, e as EventArgs)
If ispostback=false
BindData()
end if
End Sub
--- In [EMAIL PROTECTED], "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 Sponsor --------------------~-->
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/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/