Gridview and Atlas

Last post 04-04-2006 8:57 PM by ABrekken. 7 replies.

Sort Posts:

  • Gridview and Atlas

    03-15-2006, 4:34 PM
    • Member
      318 point Member
    • Rohit Gupta
    • Member since 11-02-2005, 4:36 PM
    • CA
    • Posts 86

    I have sample page which displays the search result on GridView which has Edit and Delete functionality and its working fine, and when i transferred my page for Atlas Frame work, edit and delete functionality is giving me java script error (Object not found). but search button  is able populates the Grid View with out page refresh.

    i tried to remove autoedit from Grid View  and added templete field culomns having their own asp:linkButton, and tried to capture bubbled event still same problem. i 'm confused on how do i make it run, if any one has ever done please healp me .

    Thanks in Advance

     

     

     

  • Re: Gridview and Atlas

    03-15-2006, 9:28 PM
    • Member
      173 point Member
    • riceboyler
    • Member since 05-25-2005, 3:40 PM
    • Posts 37

    Odd, I've done multiple pages with editable GridViews with no problem.

    Now, do you have the GridView doing anything client side?  If so, that may be what's causing the script errors.

  • Re: Gridview and Atlas

    03-15-2006, 9:45 PM
    • Member
      318 point Member
    • Rohit Gupta
    • Member since 11-02-2005, 4:36 PM
    • CA
    • Posts 86

    Thanks for reply! i started using Atlas just from yesterday and i'm not sure where i'm wrong, i just put my grid view in update panel control and without defining triggers element for bubbled events,  is that correct that i did or something i'm missing, Could it be possible for you to send me the code where you handled edit, update cancle events on code behind files.

    Thank you so much.

     

  • Re: Gridview and Atlas

    03-16-2006, 11:41 AM
    • Member
      318 point Member
    • Rohit Gupta
    • Member since 11-02-2005, 4:36 PM
    • CA
    • Posts 86
    riceboyler

    i think its a small job to find out what i did wrong, i've publishing my code and it is working fine when i take all that stuff out of Update Panel. please help me on that i'm a new guy in Atlas.

    <html xmlns="http://www.w3.org/1999/xhtml" >

    <head runat="server">

    <title>Page Title</title>

    </head>

    <body>

    <form id="form1" runat="server">

    <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />

    <div id="list">

    <atlas:UpdatePanel ID="up1" runat="server">

    <ContentTemplate>

    <asp:Label ID="Label1" runat="server" Text="Search by First Name:"></asp:Label>

    <asp:TextBox ID="TextBox1" runat="server" Width="107px"></asp:TextBox>

    <asp:Button ID="Button1" runat="server" Text="test" OnClick="Button1_Click" />

    <hr id="separator" />

    <asp:GridView ID="GVPerson" runat="server" Width="100%" AutoGenerateColumns="False">

    <Columns>

    <asp:BoundField DataField="EntityID" HeaderText="EntityID" SortExpression="EntityID"

    ItemStyle-HorizontalAlign="Center" />

    <asp:BoundField HeaderText="First Name" DataField="FirstName" ItemStyle-HorizontalAlign="Center" />

    <asp:BoundField HeaderText="Last Name" DataField="LastName" ItemStyle-HorizontalAlign="Center" />

    <asp:BoundField HeaderText="Gender" DataField="Gender" ItemStyle-HorizontalAlign="Center" />

    <asp:CommandField ShowEditButton="true" ButtonType="Image" EditImageUrl="~/images/Edit.jpg"

    UpdateImageUrl="~/images/Update.jpg" CancelImageUrl="~/images/Cancel.jpg" ShowDeleteButton="true"

    DeleteImageUrl="~/images/Delete.jpg" />

    </Columns>

    </asp:GridView>

    </ContentTemplate>

    </atlas:UpdatePanel>

    </div>

    </form>

    </body>

    </html>

    and on the code behind file i have

    Private Sub bindgrid()

    //Bind GridView

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    bindgrid()

    End Sub

    Protected Sub GVPerson_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GVPerson.RowCancelingEdit

    GVPerson.EditIndex = -1

    bindgrid()

    End Sub

    Protected Sub GVPerson_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVPerson.RowDeleting

    'code to Delete record

    GVPerson.EditIndex = -1

    bindgrid()

    End Sub

    Protected Sub GVPerson_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GVPerson.RowEditing

    GVPerson.EditIndex = e.NewEditIndex

    bindgrid()

    End Sub

    Protected Sub GVPerson_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GVPerson.RowUpdating

    'code to Update record

    GVPerson.EditIndex = -1

    bindgrid()

    End Sub

     

     

     

     

  • Re: Gridview and Atlas

    03-16-2006, 4:10 PM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    hello.

    well, it would be even easier for us if you can build a repro page that works (ie, can't you build a page and paste it here so that we can simply copy and run it and see if we can discover what's going on?).

    thanks.
    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: Gridview and Atlas

    03-16-2006, 5:17 PM
    • Member
      318 point Member
    • Rohit Gupta
    • Member since 11-02-2005, 4:36 PM
    • CA
    • Posts 86

    Hi Luis Thanks for reply, i did so many R& D s on that and finally got the solution, but the problen is due to some bugs in Atlas Framework and i would like to share my code and i dont have web space to publich the page so sorry i'm going to paste it here you just copy and paste that code in new page.and when you click show  it shows grid and u are not able to fire events for edit and delete it gives javascript error "object expected" but when you add attribute to form tag defaultbutton="Button1" then code runs fine. what is that Bug.

    Here is the ASPX file

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">

    <head runat="server">

    <title>Untitled Page</title>

    </head>

    <body>

    <form id="form1" runat="server" >

    <div id="list">

    <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />

    <atlas:UpdatePanel ID="up1" runat="server">

    <ContentTemplate>

    <asp:Button ID="Button1" runat="server" Text="Show" OnClick="Button1_Click" />

    <asp:GridView ID="GVPerson" runat="server" Width="100%" AutoGenerateColumns="False">

    <Columns>

    <asp:BoundField DataField="Name" HeaderText="Name" ItemStyle-HorizontalAlign="Center" />

    <asp:BoundField HeaderText="Product" DataField="Product" ItemStyle-HorizontalAlign="Center" />

    <asp:BoundField HeaderText="Location" DataField="Location" ItemStyle-HorizontalAlign="Center" />

    <asp:BoundField HeaderText="Location" DataField="Location" ItemStyle-HorizontalAlign="Center" />

    <asp:CommandField ShowEditButton="true" ShowDeleteButton="true" />

    </Columns>

    </asp:GridView>

    <br />

    <asp:Label runat="server" ID="lblMessage"></asp:Label>

    </ContentTemplate>

    </atlas:UpdatePanel>

    </div>

    </form>

    </body>

    </html>

    Here is Code Behind File

    imports System.Data

    Partial Class blank

    Inherits System.Web.UI.Page

    Private Sub bindgrid()

    Dim Table1 As DataTable

    Table1 = New DataTable("Customers")

    'creating a table named Customers

    Dim Row1, Row2, Row3 As DataRow

    'declaring three rows for the table

    Dim Name As DataColumn = New DataColumn("Name")

    'declaring a column named Name

    Name.DataType = System.Type.GetType("System.String")

    'setting the datatype for the column

    Table1.Columns.Add(Name)

    'adding the column to table

    Dim Product As DataColumn = New DataColumn("Product")

    Product.DataType = System.Type.GetType("System.String")

    Table1.Columns.Add(Product)

    Dim Location As DataColumn = New DataColumn("Location")

    Location.DataType = System.Type.GetType("System.String")

    Table1.Columns.Add(Location)

    Row1 = Table1.NewRow()

    'declaring a new row

    Row1.Item("Name") = "Reddy"

    'filling the row with values. Item property is used to set the field value.

    Row1.Item("Product") = "Notebook"

    'filling the row with values. adding a product

    Row1.Item("Location") = "Sydney"

    'filling the row with values. adding a location

    Table1.Rows.Add(Row1)

    'adding the completed row to the table

    Row2 = Table1.NewRow()

    Row2.Item("Name") = "Bella"

    Row2.Item("Product") = "Desktop"

    Row2.Item("Location") = "Adelaide"

    Table1.Rows.Add(Row2)

    Row3 = Table1.NewRow()

    Row3.Item("Name") = "Adam"

    Row3.Item("Product") = "PDA"

    Row3.Item("Location") = "Brisbane"

    Table1.Rows.Add(Row3)

    Dim ds As New DataSet()

    ds = New DataSet()

    'creating a dataset

    ds.Tables.Add(Table1)

    GVPerson.DataSource = ds

    GVPerson.DataBind()

    End Sub

    Protected Sub GVPerson_RowCancelingEdit(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCancelEditEventArgs) Handles GVPerson.RowCancelingEdit

    GVPerson.EditIndex = -1

    bindgrid()

    lblMessage.Text = "Cancel Edit Event"

    End Sub

    Protected Sub GVPerson_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles GVPerson.RowDeleting

    'code to Delete record

    GVPerson.EditIndex = -1

    bindgrid()

    lblMessage.Text = "Record Delete Event"

    End Sub

    Protected Sub GVPerson_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GVPerson.RowEditing

    GVPerson.EditIndex = e.NewEditIndex

    bindgrid()

    lblMessage.Text = "Record Edit Event"

    End Sub

    Protected Sub GVPerson_RowUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles GVPerson.RowUpdating

    'code to Update record

    GVPerson.EditIndex = -1

    bindgrid()

    lblMessage.Text = "Record Update Event"

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)

    bindgrid()

    lblMessage.Text = "Bind Grid"

    End Sub

    End Class

  • Re: Gridview and Atlas

    03-17-2006, 4:38 AM
    • All-Star
      25,662 point All-Star
    • Luis Abreu
    • Member since 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,368
    hello.

    well, you've jot another atlas bug. the problem is that your initial page doesn't generate the traditional client code script block that initializes the potback. during the atlas callback, the server sends that script block but unfortunatelly the client atlas framework filters it and doesn't add it to the client script block since it thinks that it's already there. you can check this by looking at the debug/atlas.js, method _updateScripts:

    if (text) {
    if (text.indexOf('function __doPostBack(') >= 0) {
    continue;
    }

    scriptText += text;

    }

    so, your best option is to:
    1. use the defaultbutton because that will automatically generate the necessary code
    2. use one of the getXXXreference method of the clientscriptmanager class.

    for 2 to work, try to add this to your page:

    Protected Overrides Sub OnLoad(ByVal e As System.EventArgs)
    MyBase.OnLoad(e)

    If Not Me.IsPostBack Then
    Me.ClientScript.GetPostBackEventReference(Me, "")

    End If
    End Sub

    hope this helps.
    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    EN blog:http://msmvps.com/blogs/luisabreu
  • Re: Gridview and Atlas

    04-04-2006, 8:57 PM
    • Member
      15 point Member
    • ABrekken
    • Member since 12-29-2005, 10:59 AM
    • Posts 3

    This just solved pretty much every issue I've had with Atlas so far.

    Thank you Luis!

    Andreas Brekken
    andreas@abrekken.com
Page 1 of 1 (8 items)