Trying to Make a Conditional ItemTemplate Field

Posted on 2009-04-23
Last Modified: 2013-11-26
hi all,

I'm still trying to get used to .net (from classic ASP). I have a GridView control and in one of the columns, if it has data in it already, I just want to show the data. If there is no data yet, I'd like to show a textbox. I don't want the person to have to edit / update each row individually. I want them to be able to fill in all of the rows and just hit the "save" button. First, is the save part possible? If not, then the second part doesn't do me any good. Assuming the save IS possible, how do I conditionally show the label or textbox? Then, when someone hits the save button, how do I loop through the rows to gather up all of the boxes?
Question by:DEWebWorks
    1 Comment
    LVL 83

    Accepted Solution

    The way ASP.NET grid works is that it shows the data in view mode using plain text (labels). Then you need to click on the Edit link to change the grid into edit mode in which case it would display appropriate edit controls for each cell. I think the grid does not provide the functionality which you are trying to develop. One way of acheiving this is to show a separate textbox conditionally. The user can input a value in that box and pressing the save button then insert that value in all the rows.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now