Re: DetailsView Update Issues
- From: "Steven Livingstone" <connect@xxxxxxxxxxxxxxxxxxx>
- Date: Mon, 27 Feb 2006 07:33:10 -0000
FWIW - one of the reasons is that you can use only one ControlParameter
otherwise the first CoantrolParameter is used in any ControlID reference.
You need to use Parameter(s) and capture the GridView1_Select() event
whereby you can manually set the parameters.
Can ANYONE give me a reason why you can't just state references to multiple
ControlParameter types?
steven :: http://stevenR2.com
"Steven Livingstone" <connect@xxxxxxxxxxxxxxxxxxx> wrote in message
news:uimu8zVOGHA.3196@xxxxxxxxxxxxxxxxxxxxxxx
For once i decided to use the much hyped wizards that come with Net 2
rather than the programmatic way I have always done.
What a nightmare - and some google, i see i am not the only one. A whole
day for something i could write in a fraction of the time!!
I have an object i am binding to with a two sources. One gets the master
data for a datagrid. The second happens on a select event and happily
displays the information retrieved from the object, passing in a
QueryStringParameter and a ControlParameter from the master grid and
populates a DetailsView. All works nice.
Them i go to update and i get various random errors and it is a nightmare
to debug as it doesn't throw an exception in VS and unlike the nice
programmatic view i got with ItemCreated and so on in V1, i can't seem to
step through anything.
Here is the full code - i have nothing in the code behind now, but if it
continue this way i may well go back to my old ways as this is quite
frankly a joke (for something that is really a foundational requirement).
Even is there is some subtle answer, it is never going to take off if this
is the level we have to work at.
I get "Input string was not in a correct format." and if i play around i
get the well known "non generic method" exception. The Direction field is
an enumeration.
thanks,
steven :: http://stevenR2.com
<asp:ObjectDataSource ID="ucContactList" runat="server"
SelectMethod="GetContacts" TypeName="ContactManager.Entity.ContactBook">
<SelectParameters>
<asp:QueryStringParameter Name="UserID" QueryStringField="uid"
Type="Int32" DefaultValue="66" />
</SelectParameters>
</asp:ObjectDataSource>
<asp:ObjectDataSource ID="ucContactListDetail" runat="server"
SelectMethod="GetContact" TypeName="ContactManager.Entity.Contact"
UpdateMethod="Save">
<SelectParameters>
<asp:QueryStringParameter DefaultValue="66" Name="UserID"
QueryStringField="uid" Type="Int32" />
<asp:ControlParameter ControlID="GridView1" Name="ContactID"
PropertyName="SelectedValue" Type="Int32" DefaultValue="" />
</SelectParameters>
<UpdateParameters>
<asp:QueryStringParameter Name="UserID" QueryStringField="uid"
Type="Int32" DefaultValue="66" />
<asp:ControlParameter ControlID="DetailsView1" Name="ContactID"
PropertyName="SelectedValue" Type="Int32" DefaultValue="67" />
<asp:ControlParameter ControlID="DetailsView1" Name="Direction"
PropertyName="SelectedValue" Type="Int32" DefaultValue="1" />
</UpdateParameters>
</asp:ObjectDataSource>
<table width="100%" cellpadding="0" cellspacing="5">
<tr>
<td width="10%" valign="top">
<asp:GridView ID="GridView1" runat="server" CellPadding="4"
ForeColor="Black" GridLines="Horizontal"
DataSourceID="ucContactList" AutoGenerateColumns="False"
BackColor="Gainsboro" BorderColor="#CCCCCC"
BorderStyle="None" BorderWidth="0px" Width="10%"
DataKeyNames="ContactID" ShowHeader="False" AllowPaging="True"
PageSize="15">
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White"
/>
<PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#333333" Font-Bold="True" ForeColor="White" />
<Columns>
<asp:BoundField DataField="ContactID" ReadOnly="False" Visible="False" />
<asp:BoundField DataField="DisplayName" >
<ItemStyle Width="20%" />
</asp:BoundField>
<asp:CommandField ShowSelectButton="True" SelectText="view" >
<ItemStyle Width="20%" />
</asp:CommandField>
</Columns>
</asp:GridView>
</td>
<td width="10%" > </td>
<td width="80%" valign="top">
<asp:DetailsView ID="DetailsView1" runat="server"
DataSourceID="ucContactListDetail" Height="50px"
Width="100%" AutoGenerateRows="False" GridLines="Horizontal"
FieldHeaderStyle-Width="20%" RowStyle-Width="80%">
<RowStyle Width="80%" />
<FieldHeaderStyle Width="20%" />
<Fields>
<asp:BoundField DataField="ContactID" HeaderText="ContactID"
ReadOnly="False" Visible="True" />
<asp:BoundField DataField="DisplayName" HeaderText="Handle"
ReadOnly="False" />
<asp:BoundField DataField="Description" HeaderText="Overview" />
<asp:BoundField DataField="Direction" HeaderText="Synchronization" />
<asp:BoundField DataField="Notes" HeaderText="Notes" />
<asp:CommandField ShowEditButton="True" />
</Fields>
</asp:DetailsView>
</td>
</tr>
</table>
</asp:Content>
.
- References:
- DetailsView Update Issues
- From: Steven Livingstone
- DetailsView Update Issues
- Prev by Date: filling the grid
- Next by Date: Re: Loading all files in a folder to a grid
- Previous by thread: DetailsView Update Issues
- Next by thread: How do I find Datagrid in a Page
- Index(es):