Updating row in Gridview problem

Discussion in 'ASP .Net' started by SAL, Jul 16, 2007.

  1. SAL

    SAL Guest

    I'm trying to update rows in my gridview but it isn't working. I have
    designed the table adapters via the designer and have a business logic layer
    class bound to the ObjectDataSource. In configuring the datasource, the
    Update method is set to the Update method on my business logic class which
    calls the update method on the TableAdapter.
    In the GridView, I enable editing and clicking edit seems to be working fine
    but when I click the update button for the row, the code in the business
    logic class doesn't get called. I've set a break point in there to verify
    this. The RowUpdaing even also is not getting called.
    What could I be missing with this scenario?

    Any thoughts?

    SAL, Jul 16, 2007
    1. Advertisements

  2. SAL

    nahid Guest

    i'm writing some code after view your post

    namespace BLL
    public class Sample
    DataTable oDataTable = new DataTable();
    public Sample()
    oDataTable.Columns.Add(new DataColumn("ID"));
    oDataTable.Columns.Add(new DataColumn("Name"));
    DataRow oDataRow = oDataTable.NewRow();
    oDataRow["ID"] = new Random().Next(10).ToString();
    oDataRow["Name"] = new Random().Next(20).ToString();
    public void UpDate(string ID ,string name ) {

    public DataTable getData()
    return oDataTable;

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
    <title>Untitled Page</title>
    <form id="form1" runat="server">
    &nbsp;<asp:GridView ID="GridView1" runat="server"
    AutoGenerateEditButton="True" DataSourceID="ObjectDataSource1"
    <asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
    TypeName="BLL.Sample" UpdateMethod="UpDate">
    <asp:parameter Name="ID" Type="Int32" />
    <asp:parameter Name="name" Type="String" />


    it seems all event working fine to me ....
    can you please show some code please...

    nahid, Jul 17, 2007
    1. Advertisements

  3. SAL

    SAL Guest

    Well, it would seem that my code is good. However, what has happened is that
    after clicking the "Enable Editing" property in the Smart tag, I clicked
    Edit Columns and turned the "Edit, Update, Cancel" field into a Template
    field. I did this so I could include a button in the footer without having
    to add a differet column to the grid for my button.
    It seems that after you turn that "Edit, Update, Cancel" column into a
    template that you have to blast the whole page and re-create it to get
    RowUpdating event to fire again..

    Don't know why that is but it's lame...

    Anybody got any thoughts on this?


    SAL, Jul 17, 2007
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.