GridView - Column Value Disappears

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:DropDownList ID="DropDownList1" runat="server"
DataSourceID="odsLeases"

DataTextField="LeaseName"
DataValueField="LeaseID" SelectedValue='<%# Bind("LeaseID") %>'>

</asp:DropDownList>

</EditItemTemplate>

<ItemTemplate>

<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="odsLeases"

DataTextField="LeaseName"
DataValueField="LeaseID" SelectedValue='<%# Bind("LeaseID") %>'>

</asp:DropDownList>

</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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top