Updating row in Gridview problem

S

SAL

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?

S
 
N

nahid

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?

S

hi,
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();
oDataTable.Rows.Add(oDataRow);
}
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>
</head>
<body>
<form id="form1" runat="server">
<div>
&nbsp;<asp:GridView ID="GridView1" runat="server"
AutoGenerateEditButton="True" DataSourceID="ObjectDataSource1"
OnRowUpdated="GridView1_RowUpdated">
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="getData"
TypeName="BLL.Sample" UpdateMethod="UpDate">
<UpdateParameters>
<asp:parameter Name="ID" Type="Int32" />
<asp:parameter Name="name" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>

</div>
</form>
</body>
</html>

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

thanks
nahid
http://nahidulkibria.blogspot.com/
http://www.kaz.com.bd
 
S

SAL

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?

S


nahid said:
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?

S

hi,
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();
oDataTable.Rows.Add(oDataRow);
}
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>
</head>
<body>
<form id="form1" runat="server">
<div>
&nbsp;<asp:GridView ID="GridView1" runat="server"
AutoGenerateEditButton="True" DataSourceID="ObjectDataSource1"
OnRowUpdated="GridView1_RowUpdated">
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="getData"
TypeName="BLL.Sample" UpdateMethod="UpDate">
<UpdateParameters>
<asp:parameter Name="ID" Type="Int32" />
<asp:parameter Name="name" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>

</div>
</form>
</body>
</html>

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

thanks
nahid
http://nahidulkibria.blogspot.com/
http://www.kaz.com.bd
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top