Professional Web Applications Themes

Disabling a field when editing an existing record in a Datagrid - ASP.NET General

I created an ASP.net form with an editable datagrid on it. I can create new records, and update and delete existing records. The problem I have is that I want a field in the grid to be editible when I'm editing a new record, but disabled when editable an existing record. Any ideas Mark...

  1. #1

    Default Disabling a field when editing an existing record in a Datagrid

    I created an ASP.net form with an editable datagrid on it. I can
    create new records, and update and delete existing records. The
    problem I have is that I want a field in the grid to be editible when
    I'm editing a new record, but disabled when editable an existing
    record. Any ideas

    Mark
    Mark Perona Guest

  2. #2

    Default Re: Disabling a field when editing an existing record in a Datagrid

    try it it should work
    <asp:TemplateColumn HeaderText=" Comments">
    <HeaderStyle HorizontalAlign="Center" Width="130px"></HeaderStyle>
    <ItemStyle HorizontalAlign="Center"></ItemStyle>
    <ItemTemplate>
    <asp:Label ID="lblNote" text='<%#Container.DataItem("Note")%>'
    runat="server" />
    </ItemTemplate>
    <EditItemTemplate>
    <asp:TextBox ID="txtNote" Runat="server" ReadOnly="True"
    text='<%#Container.DataItem("Note")%>' Rows="2" TextMode="MultiLine"
    MaxLength="250">
    </asp:TextBox>
    </EditItemTemplate>
    </asp:TemplateColumn>

    "Mark Perona" <mperonaearthlink.net> wrote in message
    news:5111bb05.0308120811.6964a14dposting.google.c om...
    > I created an ASP.net form with an editable datagrid on it. I can
    > create new records, and update and delete existing records. The
    > problem I have is that I want a field in the grid to be editible when
    > I'm editing a new record, but disabled when editable an existing
    > record. Any ideas
    >
    > Mark

    Alex K Guest

  3. #3

    Default Disabling a field when editing an existing record in a Datagrid

    Where do you display the fields to add a new record ?

    You cannot edit a new record, you add it, then it becomes
    an existing record, and then you Edit the existing
    record...

    So I am assuming that you are using a DataSet, Adding the
    record to the DataTable before you send it to the
    database, displaying in the DataGrid and then Commiting it
    to the database when the user confirms.

    in this case you can check the RowState of the currentrow
    of the DataTable to check if it is a new record or not.
    LEts say you have a DataKeyField ID in dtNotes datatable...
    You can put in the codebehind

    protected DataSet dsNotes;
    protected DataTable dtNotes ;

    public bool CheckNew(object myKey)
    {

    }

    <asp:TextBox ID="txtNote" Runat="server" ReadOnly='<%
    #CheckNew(Container.DataItem("ID"))%>'
    text='<%#Container.DataItem("Note")%>' Rows="2"
    TextMode="MultiLine"
    MaxLength="250">


    >-----Original Message-----
    >I created an ASP.net form with an editable datagrid on
    it. I can
    >create new records, and update and delete existing
    records. The
    >problem I have is that I want a field in the grid to be
    editible when
    >I'm editing a new record, but disabled when editable an
    existing
    >record. Any ideas
    >
    >Mark
    >.
    >
    Duray AKAR Guest

Similar Threads

  1. Editing a record from a datagrid.
    By geodev in forum ASP.NET Data Grid Control
    Replies: 0
    Last Post: October 19th, 03:20 PM
  2. Compare record field with another record field of samerecordset
    By WolfShade_2k in forum Coldfusion - Advanced Techniques
    Replies: 3
    Last Post: May 12th, 02:42 PM
  3. How can I add to existing Record Set?
    By michaaal in forum ASP Database
    Replies: 1
    Last Post: August 5th, 01:01 PM
  4. Replies: 0
    Last Post: June 2nd, 03:56 AM
  5. Replies: 0
    Last Post: July 28th, 05:04 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139