Ask a Question related to ASP.NET General, Design and Development.
-
Mark Perona #1
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
-
Editing a record from a datagrid.
I’m building a small application and I have to build it using asp.net, vb.net and my database is MSDE. I have a datagrid with a list of customers... -
Compare record field with another record field of samerecordset
:confused; ... but I don't know how to refer to field of next record in loop through recordset. Any ideas? Thanks, WolfShade -
How can I add to existing Record Set?
I use code like this in order to create a recordset and enter data into the recordset: strSQL = "SELECT * FROM InventoryItemList WHERE Desc LIKE... -
Required field validators do not while editing a row in a datagrid present in a composite control
Hi All, I have created a composite control and I have added a datagrid in it. I am dynamically adding an edit column for editing the data. Now I... -
Update existing From record with changes on new To record
I need to create a history record and update a current record from one input form. The two tables are joined with a query and the table names and... -
Alex K #2
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" <mperona@earthlink.net> wrote in message
news:5111bb05.0308120811.6964a14d@posting.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
-
Duray AKAR #3
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">
it. I can>-----Original Message-----
>I created an ASP.net form with an editable datagrid onrecords. The>create new records, and update and delete existingeditible when>problem I have is that I want a field in the grid to beexisting>I'm editing a new record, but disabled when editable an>record. Any ideas
>
>Mark
>.
>Duray AKAR Guest



Reply With Quote

