M
Mike Robbins
I have the following GridView:
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="odsRooms"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="LeaseID"
SortExpression="LeaseID">
<EditItemTemplate>
<asp
ropDownList ID="DropDownList1" runat="server"
DataSourceID="odsLeases"
DataTextField="LeaseName"
DataValueField="LeaseID" SelectedValue='<%# Bind("LeaseID") %>'>
</asp
ropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp
ropDownList ID="DropDownList1" runat="server"
DataSourceID="odsLeases"
DataTextField="LeaseName"
DataValueField="LeaseID" SelectedValue='<%# Bind("LeaseID") %>'>
</asp
ropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="RoomID" HeaderText="RoomID"
SortExpression="RoomID" ReadOnly="true"/>
<asp:BoundField DataField="RoomName" HeaderText="RoomName"
SortExpression="RoomName" />
<asp:BoundField DataField="RoomOrder" HeaderText="RoomOrder"
SortExpression="RoomOrder" />
<asp:BoundField DataField="Active" HeaderText="Active"
SortExpression="Active" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsRooms" runat="server"
SelectMethod="GetList" TypeName="Room" DataObjectTypeName="Room"
UpdateMethod="Update">
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsLeases" runat="server"
SelectMethod="GetLeases" TypeName="Lease">
</asp:ObjectDataSource>
When I run it, the editing works fine as long as RoomID is read only and
visible. If I take out the ReadOnly attribute, the value for RoomID will
disappear as soon as I click the Update link. Ultimately, I would like the
RoomID to be invisible. Unfortunately, the value seems to disappear (it
passes a 0) when I set its Visible attribute to True, regardless of the
value of ReadOnly.
Thanks,
Mike
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" DataSourceID="odsRooms"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField HeaderText="LeaseID"
SortExpression="LeaseID">
<EditItemTemplate>
<asp
DataSourceID="odsLeases"
DataTextField="LeaseName"
DataValueField="LeaseID" SelectedValue='<%# Bind("LeaseID") %>'>
</asp
</EditItemTemplate>
<ItemTemplate>
<asp
DataSourceID="odsLeases"
DataTextField="LeaseName"
DataValueField="LeaseID" SelectedValue='<%# Bind("LeaseID") %>'>
</asp
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="RoomID" HeaderText="RoomID"
SortExpression="RoomID" ReadOnly="true"/>
<asp:BoundField DataField="RoomName" HeaderText="RoomName"
SortExpression="RoomName" />
<asp:BoundField DataField="RoomOrder" HeaderText="RoomOrder"
SortExpression="RoomOrder" />
<asp:BoundField DataField="Active" HeaderText="Active"
SortExpression="Active" />
<asp:CommandField ShowEditButton="True" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="odsRooms" runat="server"
SelectMethod="GetList" TypeName="Room" DataObjectTypeName="Room"
UpdateMethod="Update">
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="odsLeases" runat="server"
SelectMethod="GetLeases" TypeName="Lease">
</asp:ObjectDataSource>
When I run it, the editing works fine as long as RoomID is read only and
visible. If I take out the ReadOnly attribute, the value for RoomID will
disappear as soon as I click the Update link. Ultimately, I would like the
RoomID to be invisible. Unfortunately, the value seems to disappear (it
passes a 0) when I set its Visible attribute to True, regardless of the
value of ReadOnly.
Thanks,
Mike