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

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

How to replace label with textbox for editing

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

Hello guys. I have a form inside a table which looks like this

HEADER1          HEADER2

asp:Label         asp:Label

asp:Label         asp:Label

asp:Label         asp:Label

asp:button text="edit"

asp:button text="save"

The labels under Header2 show data from database. I need to be able to edit this data. So when i click on Edit button the labels under Header2 should be replaced with asp:textbox so i can type new data in them and save changes with "save" button.

Please give me tips on how to approach this problem and resolve it? I was thinking of using UpdatePanel to avoid the visible page refresh.


View Complete Post

More Related Resource Links

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

TreeView (icon+check+label+textbox) binded to a recursive dataset

Hello dudes, I have a DataSet with a DataTable and I want to populate a TreeView with it's contents:Id, IntParentId, IntName,StringIcon, ???Checked, IntValue, Intthe nodes must look like:   (icon) [checked] - Name |Value|there are 2 fields updatable, checked and value, and changes made by user in the tree must update the datatable/rowI was the last 2 day looking for how to build a tree like this and have no ideas..... tks :)

Replace Text in textbox in word document using interop and asp.net

Hi all,  I'm trying to create a function to replace fields in a word document using asp.net. The fields are marked in the document using ###field### and I need to replace them with the data from the DB. The code I have works fine for the body of the word document but doesn't appear to work if the text is contained within a textbox, is there a way to correct this? Here's the code I am currently using Dim Contract as string Dim word As New Word.Application        Dim doc As Word.Document        Try            word.Documents.Open("c:\FYI.doc")            word.Visible = True             doc = word.ActiveDocument            Dim myStoryRange As Microsoft.Office.Interop.Word.Range            For Each myStoryRange In doc.StoryRanges                With myStoryRange.Find                    .Text = "###field###&quo

show value in label on textbox change event

I want to show value in label on textbox change event , means when user enter text in text box then this value should display in label  . I am using this:<asp:UpdatePanel ID="UpdatePanel1" runat="server">    <ContentTemplate>     <asp:TextBox ID="TextBox5" runat="server" ontextchanged="TextBox5_TextChanged" AutoPostBack="true"></asp:TextBox>    </ContentTemplate>    </asp:UpdatePanel>========================================================protected void TextBox5_TextChanged(object sender, EventArgs e)     {         ViewState["xyz"] = Convert.ToInt32(TextBox4.Text) - Convert.ToInt32(TextBox5.Text);         ViewState["xyz1"] = Convert.ToInt32(ViewState["xyz"].ToString()) * 100;         lbldiff.Text = ViewState["xyz"].ToString();         lblprofit.Text = ViewState["xyz1"].ToString();     }protected void TextBox5_TextChanged(object sender, EventArgs e)    {        ViewState["xyz"] = Convert.ToInt32(TextBox4.Text) - Convert.ToInt32(TextBox5.Text);        ViewState["xyz1

how to send data from dataset to textbox or label


i have dataset with sum(column1),sum(column2) , how can i take data in column1 into textbox1 or label1, column2 to textbox2. thank

Label hides TextBox



I've added simple form that is user input. I define Label text and title in constructor of this form. But the problem is, when the lael text is too long, it hides text box, as you can see on this image: http://img201.imageshack.us/i/screenfb.png/

How can I automatically change the layout, so text box is next to label?

editing the text of a textbox inside the data template of an expander header template


hello I have the following expander




<Expander Grid.Row

Executescalar and carrying the result to a label or textbox


I am trying to test if a record exists.  I am attaching this to the DetailsView_Databound event. When I run the label1 and TextBox1 do not change.

What went wrong?

 Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles DetailsView1.DataBound
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("ApplicationServices").ConnectionString
        Dim selectSql As String = "SELECT Count(*) FROM CustomersAdministrators WHERE CustomerID = @customerid)"

        Using myConnection As New SqlConnection(connectionString)
                Dim myCommand As New SqlCommand(selectSql, myConnection)
                myCommand.Parameters.AddWithValue("@CustomerID", DetailsView1.SelectedValue())
                Dim count As Int32 = Convert.ToInt32(myCommand.ExecuteScalar())
                If count > 0 Then
                    Label1.Text = "Moomba"
                    TextBox1.Text = count.ToString
                    TextBox1.Text = "Available"
                End If

            Catch ex As Exception

            End Try

        End Using
    End Sub

How to make a textbox or a label in my own webpart connectable with webparts from sharepoint webpart

I'm developing a webpart which need to be able to receive data from standard webparts from sharepoint.
My webpart needs to get data from a sharepoint formfield in an editform from a list.
I know how to connect 2 standard sharepoint webparts with sharepoint designer. But I can't seem to figure out how to connect my own webpart with a webpart from sharepoint. All I can find on the internet are examples where you need to have your own provider and consumer, not just the consumer.
So basicly I need my webpart to be able to connect with sharepoint webparts, just one connection is enough.

I'm developing for sharepoint 2007 with visual studion 2008. 

populate label/textbox from dropdownlist in insert item template


I've been trying to find a solution to my problem for about 2 days now, and have found nothing.  I am new to .net and not really sure how to accomplish this. 

I have 4 tables in a database, Vendors, RepairCos, Cons, ConRepairHistory.   What I'm trying to do is make a page called SendOutForRepair.aspx that has a insert item template where the first control is a dropdownlist that is attached to the Cons table (got this figured out) and is populated with the Serial Number field.  I would like the selection from the dropdownlist to populate the 2nd control (VendorID) that is also from the Cons table.

example record from Cons Table:  Serial number      VendorID
                                                      508585                     1

so when 508585 is selected in the dropdownlist, it would populate VendorID with 1 (this is my issue)

once this happens, the user would fill in the other fields (hours, issue, repairco (al

How to set a Label style when the target TextBox has focus?

I would like to highlight a label when the associated textbox has focus. This works:

<Label Grid.Row="1" Grid.Column="0" Target="{Binding ElementName=CountryCode}">
    <Style TargetType="{x:Type Label}">
          <DataTrigger Binding="{Binding ElementName=CountryCode, Path=(IsFocused)}" Value="True">
              <Setter Property="Foreground" Value="Blue" />
   <AccessText Text="{Binding Path=CountryCodeLabel}" />
<TextBox Grid.Row="1" Grid.Column="1" Name="CountryCode" Text="{Binding Path=CountryCode}" />

But I have a bunch of these textboxes, so I'd prefer to template the style. This works:

<Style x:Key="HighlightOnFocus" TargetType="{x:Type Label}">

Textbox Editable GridView in ASP.NET

This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

Highlighting Rows with TextBox OnFocus

In another article I explained that how you can make the rows of the GridView control clickable and highlight them when they are clicked. In this article I will explain that how you can highlight the GridView rows when you focus on the TextBox which is contained inside the GridView control.

Editing the Data in a GridView

In addition to deleting a GridView's underlying data, another common need is to allow end users to edit the data displayed in a GridView. With ASP.NET 1.x's DataGrid control, editing the data is certainly possible, but requires creating three event handlers and writing a dozen or so lines of code. With the GridView and ASP.NET 2.0, it is possible to create an editable GridView without writing a single line of code! All of the necessary functionality is encapsulated within the GridView.

The GridView allows editing on a row-by-row basis. An editable GridView contains an additional column with an Edit button in each row. When the end user clicks on an Edit button that row becomes editable, causing the Edit button to change to Update and Cancel buttons and the other columns to become TextBoxes. The end user can then update one or more column values and click Update to save their changes.

How Do I Enable Inline GridView Editing?

Now that you have created a site with Edit and Details views, how do you enable inline editing in a GridView control? This video shows you how, and also touches on routing.

Editable Gridview with Textbox, CheckBox, Radio Button and DropDown List

This is an example of an editable gridview containing different ASP.NET controls. When user wants to edit values in gridview, she/he can use these controls to edit existing values in Gridview Edit Mode.

Using the Code

watermark textbox using Ajax control

This is pretty simple compared to jquery. Since we need refer a dll only. we dont want any script for this. we just include that reference into our website.
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