Forms Data Controls :: Excluding Subcontrols Of A FormView From 2-way Databinding?

Sep 3, 2010

So we use formviews all over the place that recently we've started putting user controls inside that have databinding controls inside them. In this instance it's a grid so

<formview>
<edititemtemplate>
<dynamiccontrol DataField="name" />
<customGrid DataField="addresses">
<columns>
<dynamiccontrol DataField="city" />
</columns>
</customGrid>
</edititemtemplate>
</formview>

That's the basic sitch. We have the customGrid, a usercontrol, bind to a collection on the main DataItem, and it contains dynamiccontrols (DD4) in its column templates so stuff in the cells displays right. (in reality, the customGrid is inside a dynamiccontrol like all the other fields here and is loaded based on ui hints, I've just stuck it in the pseudo-markup here for illustration). This works a charm, up until you try and update the formview. At that point, the FormView grabs all the keys from all the dynamiccontrols in its edititemtemplate, including keys and values from dynamiccontrols insde the customGrid control. Obviously this doesn't work as those are for an "address" object or something, and the formview is bound to a "person" object. What i desperately need is a way, inside customGrid, to stop FormView from getting out all the dynamiccontrol keys and values inside it. Overriding DataBindChildren doesn't work, nor DataBind. I don't know at what point or how the FormView queries its instantiated template for all the 2-way databinding controls it has inside it, but if I could get at that maybe I could figure something out. Or else, if I could make the customGrid stop sending back all the values inside it.

I tried overriding the formview's OnItemUpdating but that only so much; I can remove entries from the e.NewValues collection if they don't exist on the DataItem, but that doesn't if your custom sub control is binding items with fields of the same name as your main dataitem. There must be a way to abort this 2 way databinding in the custom control.

View 1 Replies


Similar Messages:

Forms Data Controls :: Formview And Databinding?

May 18, 2010

I am trying to bind a FormView on runtime in codebehind (instead of using predefined datasource).

[Code]....

GetCase will return a DataTable with just 1 row.Then on my aspx:

<asp:FormView DefaultMode="ReadOnly" runat="server" ID="FormView1" DataKeyNames="complaint_ID">
<ItemTemplate>
<asp:Label ID="lblComplaintID" runat="server" Text="<% Eval('case_ID'); %>" />
</ItemTemplate>
</asp:FormView>

View 2 Replies

Forms Data Controls :: DataBinding And DataBound FormView's Events?

Dec 27, 2010

I have a very simple form that contains a FormView Control Bound with a SqlDataSource, The DefaultMode of the FormView control is "Insert". I noticed that when I run the page for the first time, the databinsing and databound events of the FormView Control occurs after the PreRender Event of the page ! I know very well the life cycle of a page, but I dont know when the data binding occurs in the life cycle of a page and if it can differ from a control to another.

Is there an article or a tutorial explaining all those things.

View 2 Replies

Forms Data Controls :: Databinding To FormView Child Control Programatically?

Mar 2, 2010

I've got a FormView control for which I'm Viewing, Inserting and Updating to a MS SQL Database.

Instead of adding a SqlDataSource control to the page, I've created it in the code behind and declaring the properties/attributes for it during Page_Load.

At the moment, everything is bound and working fine, but I'm having an issue Databinding to the child controls in my FormView with parameters set in the code behind.

This is where I'm at.

[Code]....

[Code]....

So, I need to be able to bind the DS.InsertParameters.Add("PageTitle", ---) with the txPageTitle control in the Insert Template, same with the PageURL to txPageURL. Is there any easy way to do this from the code behind? I can't seem to find a way to add a parameter without needing to assign it a value.

View 7 Replies

Forms Data Controls :: How To Calculate The Difference Between Two Dates Excluding Sunday & Saturdays

Dec 27, 2010

i need to caluculate diffrence between two dates exculding saturdays & sundays

string startdate1 = 12/01/2010;
string enddate1 = 12/31/2010;

datetime diff = Convert.todatetime(startdate1 - endate1) how to exculde weekends

View 1 Replies

VS 2008 - Databinding Dependant Dropdpwns In Formview?

Jan 5, 2010

I am trying to do dependent dropdown in a formview. I am getting this error when I select the DDL1. I ma using VS2008 and with code behind in VB.

[code]....

View 10 Replies

LoginView Inside FormView Control Is Not Databinding On PostBack?

Apr 20, 2010

I have a fairly simple form:

[code]....

However, once the update is finished (and I call e.Cancel = true), the LoginView control does not databind its children... so they are all blank. The FormView's viewstate is still fine, as all the rest of the controls outside of the LoginView appear fine. I even handle the FormView_DataBound event and a Trace shows that the FormView is being databound on postback.

Why then is the LoginView not keeping its ViewState/being databound? Here's a sample code snippet showing the flow:

[code]....

View 1 Replies

Forms Data Controls :: Accessing Master Formview Data From A Nested Detail Formview?

Sep 10, 2010

I would like to ask if it is possible to access data on a master FormView from a nested detail FormView.

I have a main form (master) with several tabs (detail) and would like to display a label with text from main form that is hidden by the tab at the moment of editting. My asp page looks like this.

[Code]....

Is it possible to get the value of the label CompanyTextLabel from CompanyTextBox using just ASP.NET expressions or something similar without writing c# code in .cs file?

View 4 Replies

Forms Data Controls :: Set Value To Textbox In Nested Formview From Parent Formview Label?

Apr 10, 2010

I have a nested formview. I need to set a value for a textbox when I'm in insert mode from parent formview which is editmode.

View 4 Replies

Statement Within Formview / Error Databinding Methods Such As Eval(), XPath() And Bind()?

Jan 22, 2010

i have a FormView, it renders fields from a SQLServer database but also much static text specific to the database value I get. I dont know if this can be done in the code behind and put all this in a function . I put it in my formview

<ItemTemplate>
<% If Eval("Feature1") = "Yes" Then %>
<%# Eval("Username") %> A lot of text
<% elseIf Eval("Feature1") = "No" Then %>
<%# Eval("Username") %>

A lot of different text

<% End If %>
</ItemTemplate>

If I do the code above I get error message:

Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control. Can this be done within the formview?

View 1 Replies

Forms Data Controls :: Formview That Use The Formview Iteminserted Event?

Jan 24, 2010

I have a formview that use the formview iteminserted event. The information inserts into the formview fine, but all cells blank out after the insert. How can I make it so I can show all the values I have inserted show up in the formview after the inteminserted event?

View 2 Replies

Forms Data Controls :: FormView Clearing Value Set In Page_load / Initialize A Date Field In The FormView to Today's Date?

Sep 2, 2010

I have a page with a FormView on it. The page is strictly for adding records to a Table. I have the FormView bound to an EntityDataSource and everything works greate except for one thing.

I want to initialize a date field in the FormView to today's date. So, in my page_load event I have:

if (!Page.IsPostBack)
{
//Initialize SetupDate to today.
TextBox setupdate = (TextBox)fvJob.FindControl("txtSetupDate");
setupdate.Text = DateTime.Now.ToShortDateString();
}

The first time this page loads, the txtSetupDate field is initialized.

Although, and subsequent loads of the page doesn't initialize the Text Box. I step through the code in the debugger and I can see that the code is executig, but something (the FormView bind?) is "clearing" the Text Box.

View 6 Replies

Forms Data Controls :: Databinding Return 0 Value?

Sep 27, 2010

I'm wondering why I'm getting value 0 for both "NumberOfReplies" &NumberOfRepliesinPercent ?

[Code]....

<asp:Repeater id="rptReplies" runat="server">
<%#DataBinder.Eval(Container.DataItem, "NumberOfReplies")%>
<%#DataBinder.Eval(Container.DataItem, "NumberOfRepliesinPercent")%>

[code]...

View 4 Replies

Forms Data Controls :: Databinding A Dropdownlist Within A Gridview?

Mar 29, 2010

I have a gridview in which I have two drop downs. One is populated with values that are static, so I have a regular sub that does that in the code behind. I tried to add code for databinding the other ddl to a datatable. I cannot get this to work. It just comes up empty. My asp code is fine, and the datatable definately has data in it - just nothing gets populated.

One other thing - the code for the static ddl has worked fine, but when I add this other block (either to the same sub as that, or dow the rowdatabound event) the static one doesn't work either.

[Code]....

View 2 Replies

Forms Data Controls :: DataBinding + Extension Method?

Oct 24, 2010

Inside my repeater I'm calling an extension method like so:

[Code]....

he above is giving me an "Object not set to an instance of a object" exception inside the extension method. If I comment the above expression out, it works fine, and the items are binded wtih no problems.

View 1 Replies

Forms Data Controls :: Trying To Use Dynamic Object In A Databinding Tag

Sep 18, 2010

im trying to use dynamic object in a databinding tag , it gives me error that the property does not exists even though i can see all the properties there in the vs debug mode

here is what im trying to do:

C#:

my method signature:

public static dynamic MyMethod()

ASPX:

in control itemtemplate:

<%# MyMethod().SomeProperty %>

if also trite the other way:

C#:

public static object MyMethod()

ASPX:

<%# ((dymanic)MyMethod() ).SomeProperty%>

But i dont know why it cant resolve the properties , even though i can see them when the databinder control throws an exception (its working fine outside the databinder tag (ie normal aspx tags <% %>)

View 1 Replies

Forms Data Controls :: How To Postpone Gridview Databinding

Sep 30, 2010

I have a GV & a FV both linked to same sqldatasource.

When a GV row is clicked, the FV becomes available for editing the row but the GV as a result is reduced to only that row. I want to GV to remain showing all rows. I am using GV selected_index event to invoke "SqlDataSource1.SelectCommand=

View 7 Replies

Forms Data Controls :: DataBinding Event Not Firing?

Feb 18, 2010

I've created a web page that has a GridView control bound to an

View 8 Replies

Forms Data Controls :: Databinding With Templated Used Control?

Jan 27, 2010

I've created a templated user control by following the example on the microsoft support pages. I won't post it all but the important part of the CS file looks as follows:

[Code]....

I'm not sure if the whole _CurrentDataItem business is required, I don't think so.The problem I've got, is that I've tried nesting it inside a FormView control so I can use it to display a record from a database. My ASPX looks like this:

[Code]....

Now, the bound properties (TitleText and TitleSubText) bind correctly, but the nested / template content is blank when the page loads. I'm not sure if this is something to do with the order in which everything is loaded or because I'm missing some code in the SimpleTemplate to get it to bind (etc.).

View 2 Replies

Forms Data Controls :: FormsView DataBinding In Code Behind?

Sep 26, 2010

I have a forms view with an EditItemTemplate. I would like to populate the EditItemTemplate using the code behind vs. mixing the data in the UI as so:

text='<%#Bind("Question") %>'

At what point do I do this? I thought it would be on FormView_DataBinding, but there is no e.item.dataitem like other databound controls. My issue is that I need to check criteria of the data prior so I know which inputs to make visible, to set properties of controls within the EditItemTemplate, and manipulate the data prior to binding (less of an issue as I can always just tweak the data prior to binding, but it doesn't solve my other problems).

View 2 Replies

Forms Data Controls :: Databinding TemplateFields In DetailsView?

Aug 12, 2010

I am using the following to show a Yes/No for a boolean in my database:

[Code]....

I want to do something similar with a drop down list but I am having problems making the current value the selected value in the dropdownlist:

[Code]....

I am getting the error:

Databinding expressions are only supported on objects that have a DataBinding event.

System.Web.UI.WebControls.ListItem does not have a DataBinding event.

View 4 Replies

Forms Data Controls :: Databinding With A Textbox In A Tab Within A Gridview?

Apr 8, 2010

I am having issues with databinding a textbox within a tab within a gridview. The textbox displays the data information properly; however when I try to edit a row in my gridview anything I type within that textbox is not saved in the database. Also my other fields for my gridview are editable, I am only having issues with this textbox within a tab. Here is the code:

[Code]....

View 3 Replies

Forms Data Controls :: ImageLinkButtonField Does Not Have A DataBinding Event?

Sep 20, 2010

I have a custom DataControlField class that works fine but when I try to use <%# Eval('???') %> with it I get an error."Databinding expressions are only supported on objects that have a DataBinding event. SharedG.ImageLinkButtonField does not have a DataBinding event."I can't get this to work,the DataControlField dosen't seem to have a DataBinding event to override or anything.I could use a normal templatefield itemtemplate etc.with eval but I don't want to rewrite this all the time.
[Code]....

want to use it:
[Code]....

View 1 Replies

Forms Data Controls :: Databinding A Gridview Programmatically?

Nov 23, 2010

I was wondering what would be the best pratice to databind a gridview programmatically.Normally i put my databind code in the page_load() but is there a way to reduce the number of times the databind method is called?I mean... the page_load() method seem to be called a lots of times when doing callbacks with the grid.

View 5 Replies

Forms Data Controls :: Changing Data In A Gridview During Databinding Or After Databound?

Feb 2, 2010

im building a simple message messenger web application, i currently have a column in my database dedicated to the status of a message. Its bound to the third column in a datagrid.

After converting the column to a TemplateField and using a Label to fetch the data how do i change the text from the database to a small message, e.g. if the data in the database (as an interger) is 0. how do i change the interger to a string to display "UnRead". Do i need to do this during the databinding call or after the grid has been databound?

I know it would be easier to use a boolean and checkbox control but the interger column represents more values than true or false.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved