473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

usercontrol, databind and updating a object data source

I have a user control that is in a FormView using an ObjectDataSource. When
the page renders the form correctly displays the data from the data source.
When I then change data and hit update, my update method gets called, but the
data is unchanged.

aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="TestObjectWeb._Default" %>

<%@ Register Src="WebUserControl1.ascx" TagName="WebUserControl1"
TagPrefix="uc1" %>

<!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>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
DataObjectTypeName="TestObjectWeb.test"
SelectMethod="GetTests" UpdateMethod="UpdateTest"
TypeName="TestObjectWeb.TestContainer"
OldValuesParameterFormatString="old"
ConflictDetection="CompareAllValues"></asp:ObjectDataSource>

</div>
<asp:FormView ID="FormView1" runat="server"
DataSourceID="ObjectDataSource1" DefaultMode="Edit">
<EditItemTemplate>
<uc1:WebUserControl1 id="WebUserControl1_1" runat="server" >
</uc1:WebUserControl1>
<asp:LinkButton ID="UpdateButton" runat="server"
CausesValidation="True" CommandName="Update"
Text="Update">
</asp:LinkButton>
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel"
Text="Cancel">
</asp:LinkButton>
</EditItemTemplate>
</asp:FormView>
</form>
</body>
</html>

object data source code
namespace TestObjectWeb
{
public class TestContainer
{
private List<Test_tests = new List<Test>();

public TestContainer()
{
_tests.Add(new Test());
}

public List<TestGetTests()
{
return _tests;
}

public void UpdateTest(Test current, Test old)
{
}
}
}
data object code
namespace TestObjectWeb
{
public class Test
{
private string _name = "Joe";

public Test()
{
}

public string Name
{
get { return _name; }
set { _name = value; }
}
}
}
ascx code
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="WebUserControl1.ascx.cs" Inherits="TestObjectWeb.WebUserControl1"
%>
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>'
></asp:TextBox>


Aug 1 '08 #1
0 1394

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Russ | last post by:
I have a Datagrid that is in a user control on a webform I am creating and when I click on the edit button of the datagrid nothing happens. I have to click the button 2 times to get the event to...
3
by: Marty McDonald | last post by:
I have <asp:Table... </asp:Table> on my webform. In codebehind, I populate a DataTable whose data should appear in the asp:Table. I created my own code to populate the asp:Table with the...
0
by: Colin Ramsay | last post by:
Hi all, I don't normally post swathes of code like this but I am truly banging my head off my desk here... I've dynamically created a datagrid within a usercontrol. There are two columns...
4
by: sebastien | last post by:
Hi, In page_load : If Not Page.IsPostBack Then Dim myUC As UserControl = LoadControl("ficheProspects.ascx") myUC.ID = "FicheProspects1" End If In another Sub i need to find my control :
3
by: Nick | last post by:
I've created a user control that extracts data from a database. The VB code is all contained in a code-behind file. I'm trying to extract a value from the request.querystring but keep getting...
1
by: freshRecruit | last post by:
Hi, I am having a problem, and is driving me nuts and my deadline is fast approaching. Please do help me.. This is a webapplication with a usercontrol which has some buttons for adding,...
6
by: p.mc | last post by:
Hi all, I'm having major problems with a userControl which contains a datagrid. My problem concerns data binding. The Page_Load() procedure calls the DataBind procedure to bind the datagrid...
5
by: tshad | last post by:
I get an error when running my Javascript inside my UserControl. It works fine if I put the UserControl Data directly in my Web Page. The stripped down code is: <script language=javascript>...
1
by: Florian Paulus | last post by:
hallo group! i have a user control that using a listbox and a dataset to fill it. usually i can give some parameters in the form of public properties to user controls for example : ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.