C
Cas
Hi,
I defined a detailsview in insertmode in the .aspx file.
In the code-behind, i created 6 fields and adding them to the detailsview.
Independantly of the detailsview, I use the datareader to read data from a
database.
Now, when the second field of the datareader (dtreader.GetString(1))
contains an "x", the field created and added to the detailsview must be
read-only.
I tried in the code below, but i can still input data into that field.
Everything works except the read-only property.
Thanks for hrlp
Cas
My code:
In aspx file:
----------
.....
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="....></asp:SqlDataSource>
<asp
etailsView ID="DetailsView1" runat="server" AutoGenerateRows="False"
CellPadding="3" DataSourceID="SqlDataSource1" DefaultMode="Insert">
</asp
etailsView>
......
In code-behind file:
------------------
......
For i = 0 to 5
dtreader.Read() 'connected to database
bf(i) = New BoundField
bf(i).DataField = "fld" & i + 1
DetailsView1.Fields.Add(bf(i))
If dtreader.GetString(1) = "x" Then
DetailsView1.Fields(i).HeaderText = dtreader.GetString(2)
DetailsView1.Fields(i).HeaderStyle.Font.Underline = True
bf(i).ReadOnly = True
' this doesn't work
'DetailsView1.Fields(i).readonly
'doesn't exist
End If
next
......
I defined a detailsview in insertmode in the .aspx file.
In the code-behind, i created 6 fields and adding them to the detailsview.
Independantly of the detailsview, I use the datareader to read data from a
database.
Now, when the second field of the datareader (dtreader.GetString(1))
contains an "x", the field created and added to the detailsview must be
read-only.
I tried in the code below, but i can still input data into that field.
Everything works except the read-only property.
Thanks for hrlp
Cas
My code:
In aspx file:
----------
.....
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="....></asp:SqlDataSource>
<asp
CellPadding="3" DataSourceID="SqlDataSource1" DefaultMode="Insert">
</asp
......
In code-behind file:
------------------
......
For i = 0 to 5
dtreader.Read() 'connected to database
bf(i) = New BoundField
bf(i).DataField = "fld" & i + 1
DetailsView1.Fields.Add(bf(i))
If dtreader.GetString(1) = "x" Then
DetailsView1.Fields(i).HeaderText = dtreader.GetString(2)
DetailsView1.Fields(i).HeaderStyle.Font.Underline = True
bf(i).ReadOnly = True
' this doesn't work
'DetailsView1.Fields(i).readonly
'doesn't exist
End If
next
......