.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

textbox in readonly mode does not bind in formview

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net


I was surfing the web about a bug that has asp.net about unability to bind a textbox which was set to readonly and does not bring any value when inserting data.  Some sites claim that readonly should be set in code behind in page load but it haven't work for me.

            TextBox txtCuota = (TextBox)fvPrecios.Row.FindControl("txtNewCuota");
            txtCuota.Attributes.Add("readonly", "readonly");


I was thinking in using a label instead for binding data but it didn't work either.  Is there an easy way to do this? 
Maybe a hidden field?




View Complete Post

More Related Resource Links

Populate textbox in FormView Control in Edit Mode with querystring

Can someone please tell me what I am doing wrong here. I am simply trying to get a querystring value and pass it to a textbox in a formview with the default view set to edit mode.     Protected Sub fv_Detach_Engine_DataBound(ByVal sender As Object, ByVal e As EventArgs) Handles fv_Detach_Engine.DataBound        If fv_Detach_Engine.CurrentMode = FormViewMode.Edit Then            Dim tbx_IDProfileAccount As TextBox = TryCast(fv_Detach_Engine.FindControl("tbx_IDProfileAccount"), TextBox)            If tbx_IDProfileAccount Is Nothing Then                tbx_IDProfileAccount.Text = Request.QueryString("IDProfileAccount")            End If        End If    End Sub  

FormView ReadOnly mode


Is there any way to display a formview in readonly mode even when the datasource is empty? It shows up in InsertMode if I set the defaultmode to that but I want it to show up in readonly even if there is no data but right now it just doesn't display at all. Is there a way to do this? 

how to bind Dropdownlist based on textbox values



I have one drodownlist which show data based om textbox values...

Let us consider i have 

Select Name from table1 where Type IN(@typ)

here @typ is textbox values

here for example textbox will have some thing like this L1,L2,L3..

How to filter Name based and shown in drodownlist based on this L1,L2,L3(on textbox)..

Help me in this

Formview + EditItemTemplate + Bind + PageLoad + Prerender = Confused


I am working with a formview edititemtemplate.  Currently in my page load, i have some stuff that would show or hide certain panels based on dropdownlist values.  These dropdown values get binded during page load.  I need to be able to change the values/dropdowns, without rebinding the old data, and updating the visibility of the panels based on predefined rules.

I have experimented with putting my formview.databind() in page load if isnotpostback, in prerender, in prerender if isnotpostback.   I have tried my rules (ex if ddlState.selectedvalue = "DE" then pnlDelaware.visible = "true") in the page load, and the page render.   I'm just not sure how to get the stars aligned here.

The closest i have come is having the databind in the pageload if notispostback, and the rules in the prerender.   However I get an error "dropdownlist has a SelectedValue which is invalid because it does not exist in the list of items.


Changing a textbox's readonly property right before update on a gridview


I have a gridview with a date field. I don't want the user to be able to type in their own date and mess up the format so I made the property readonly. That date is then set by a point and click interface. This is all working fine but when the user clicks update this field doesn't update because it's readonly. If i turn readonly off it works so is there a way to turn off the readonly property right before submit?

How to force a textbox to have insert mode off in WPF 4 vb.net.

I need my textboxs on my WPF form to act like the traditional insert key function where you could override characters as you type and not insert them. IE I need to turn off the defualt insert characters feature. It also has to be able to be turned on when needed. Thank you for reading, hope you can help!~Justin

Want to show FormView in Edit mode with specific table columns depending on their Genre??

hi, I have  a table in my database called "Profiles". This holds data on Female and Male personal characteristics. On my aspx, I have a formview in edit mode which is binded to an object data source with a GetDataByUserId Select method which retrieves data from the "Profiles" Table via a DAL. The "Profiles" table has some columns which relates to females only and some just males and some are generic to both. See example below     UserId - / of Type GUID GenreId /  of Type BOOL. Hip Size (For females) Dress Size ( For Females) ChestSize (For Men ) TrouserSize (For Men) Weight ( For both )   When the User logs in , they go to an update Page which has the Formview in Edit Item Mode and contains drop down Lists which are binded to the Users Selected Value. The DDL are in turn bound to their related table such as HIP, Dress, Chest, Trouser etc. Objective If a female user logs in I just want to show them the (Hip Size) DDL  and DressSizeDDL in the Edit item template of the formview and not the ChestSize DDL or  TrouserSize DDL. At present the GetProfileByUserId returns all colums from the table My question is how do I do this and just show DDL which are relevant to the Female or Male Only. In some cases the user may not have selected an item in the previous form so they could also be

Can't render FormView with EntityDatasource in Design Mode

Hi Guys! I'm not sure if I'm placing this in the right spot but since it has to do with Entity Framework I put it here.  Here's the deal.  I have a FormView bound to an EntityDataSource.  The FormView is a part of a user control.  In design view on the user control, the formview and the entity datasource show up as expected.  However once I put the user control in an aspx page, the formview won't show up.  The entity datasource shows, but the formview doesn't.  Instead I get this message in design view: "There was an error rendering the control.  Value cannot be null.  Parameter name: owner"  I don't have any parameters in my datasource or formview called owner.  Is it talking about the database owner. By way of comparison, I put a SqlDatasource on the page and tied it to a formview.  It showed in design view on both the user control and the aspx page.  So that led me to believe it has something to do with the formview being bound to the entity datasource.  I am using Visual Studio 2008 Team Foundation. Thanks!

Not able to bind textbox with javascript textbox? Why?

I'm trying to use a javascript Date and Time calendar in my Insert and Edit templates in a Detailsview that is bound to SQL Fields. The reason I am trying the javascript date time selector is that I need to have the date and time, the asp.net one is just the date part. I guess my first question is this possible? I tried using it with an asp:textbox on just a plain aspx page and it works like a charm, however when I add it to the detailsview i keep on getting the "Error: Object required"  am I missing a step here?  That and seeing as I'm using a site master page where exactly do I put the:  "<script type="text/javascript" src="datetimepicker_css.js"></script> "   <asp:TemplateField HeaderText="Start Time" SortExpression="StartTS"> <EditItemTemplate>   <asp:TextBox ID="STEditCalendartxt" runat="server" Text='<%# Bind("StartTS") %>'>    </asp:TextBox> <a href="javascript:NewCssCal('STEditCalendartxt','mmddyyyy','arrow',true)"> <img src="images/cal.gif" width="16" height="16" alt="Pick a date"></a>  </EditItemTemplate> Any assistance would be greatly welcomed.

Unable Set Value of TextBox In FormView

I need to set the value of TextBox in a FormView when the mode changes to Insert. But when I was trying to get it to work, neither one of the code blocks below worked. The value was not set, despite the TextBox being found. Furthermore, the 'test' label text wasn't being set. I know for certain that both events are firing. I had added the test label to disploay the mode or newmode of the FormView but the label wasn't being set at all. Protected Sub FormViewMessageDetail_ModeChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.FormViewModeEventArgs) Handles FormViewMessageDetail.ModeChanging 'If FormViewMessageDetail.CurrentMode = FormViewMode.Insert Then Dim TextBoxMessageDateTime As TextBox = CType(FormViewMessageDetail.FindControl("TextBoxMessageDateTime1"), TextBox) TextBoxMessageDateTime.Text = Now.ToString 'End If Dim Test As Label = CType(FormViewMessageDetail.FindControl("Test"), Label) Test.Text = Now.ToString End Sub Protected Sub FormViewMessageDetail_ModeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles FormViewMessageDetail.ModeChanged 'If FormViewMessageDetail.CurrentMode = FormViewMode.Insert Then Dim TextBoxMessageDateTime As TextBox = CType(FormViewMessageDetail.FindControl("TextBoxMessageDateTime

Binding A ReadOnly DP with OneWayToSource mode, possible?


Hi guys,

I have a UserControl with a ReadOnly property.

Using MVVM, I want the View to be able to bind to the VM with a OneWayToSource mode.

But I get an error

The property cannot be set because it does not have an accessible set accessor.

Any idea for this issue?



Bind An Already Bound TextBox to ComboBox SelectedItem


Hey all,


If I have a TextBox that is already two-way bound to something, but I also want it so when a ComboBox SelectedItem changes, then the TextBox's Text property is set to the new SelectedItem.


Here's what I have so far, I added the comment where the TextBox is, which I would like to also be bound to the ComboBox below this.


        <ListView Grid.Row="2" 
             DataContext="{Binding ScriptParameters}"

Switch FormView to Edit Mode from Repeater ItemCommand


The following code successfully displays a record in a FormView and sets the FormView mode to 'Edit' when the user clicks on a LinkButton within a Repeater, however the record is not Updated. If I don't change the .SelectCommand and call .DataBind, I'm able to update the first record that is displayed. Naturally that's a moot point because the idea is to be able to update the record that the user selects in the Repeater. Because of the design of the FormView and Repeater, the record *must* be updated via the FormView. Updating the record via the Repeater is not an option.

    Protected Sub RepeaterMessages_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs)

        Select e.CommandName
            Case "Edit"
                SqlDataSourceMessageDetail.SelectCommand = "SELECT [Id], [MessageDateTime], [MessageOwner], [Subject], [Body], [AllowReplies], [ExpirationDateTime], [IsCityWideMessage], [DepartmentId], [BranchId], [CompanyFacilityId], [ShowNumber], [IsHighPriority], [UpdateDateTime] FROM [Messages] WHERE ID = " & e.CommandArgument

textbox in formview


hi all..


i have create a simple form using form view...

in my form i have use TextBox..(Id = TextBox1)

when am trying use that textBox in my cs page i can't get id..

How to get textbox in cs page

textchange event not working from textbox on formview


Hello guys.  I have a formview which in insertmode is required to assign a value to a textbox from another on textchange event.  I can't get it working.

here's formview code (in bold:  event call:

<asp:FormView ID="fvPrecios" runat="server" AllowPaging="True" DataSourceID="OdsPrecios"
        Style="position: relative" CellPadding="4" ForeColor="#333333"
        DataKeyNames="precnume" >
            <table style="position: relative" width="400">
                    <td style="width: 62px; height: 26px">
                        <asp:Label ID="lblEditNombre" runat="server" Text

Limit characters in multiline textbox on formview



I have this working perfectly on a normal webform without a master page or formview.

Label1 is counting the values in TextBox2 and limiting them to 10.

I need this to work in a formview with a master page but I just can't get it to work. Can someone please advise how I use this with the controls being in a formview or even a detailsview.

Thanks for any help.

    function checkLength(con)

if(con.value.length >= 10)

return false;



document.getElementById('Label1').innerHTML = (9 - con.value.length) + ' Chraracters Remaining';return true;


function setRemaining()

document.getElementById('Label1').innerHTML = (10 - document.getElementById('TextBox2').value.length) + ' Chraracters Remaining';

if (document.getElementById('TextBox2').value.length > 10)

document.getElementById('TextBox2').value = document.getElementById('TextBox2').value.substring(0,10);



How to validate a GridView textbox in edit mode


I am working with VWD Express and Visual Basic. Please take this into consideration if you are willing to answer my question.

I do have the following code for a GridView.

        PageSize="100"  >

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend