Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Gridview/Detailview update with one-to-many relationship 1

Status
Not open for further replies.

jamin20

Programmer
Feb 13, 2012
14
0
0
CH
Hi all,

I have a Gridview/Detailview page that implements a one-to-many relationship.
Gridview contains "Document" items and Detailview contains "Contact" items. The selection mechanism works fine.

When I update a Contact, the Document_ID is NULL and the update fails !!

Any one to help me understand what i'm missing ?
tia
Jamin
 
Can't help you if you don't post any code. Also, if you are using one of the DataSource controls, I suggest you get rid of it and write the SQL yourself. You won't be able to debug the actions of a DataSource control.
 
thx jbenson001 for your quick answer!!
that's what I think I will have to do, any tutorial or example?
tia
jamin
 
Do you need help with SQL? There is a forum for that here. I would write any SQL I need in a stored procedure. This is for many reasons. Figure out what you need help with and post in the appropriate forum. There are lots of good people here to help. Also, Google is a great place to search and get examples. You just have to figure out what exactly you are looking for. Post back and let me know..

Jim
 
Hi Jim,
it should be ok with SQL, I meant a piece of code to switch from the declarative SqlDataSource to the vb.net coding.
I managed to do it, now I'm facing a "too many parameters" error ...
Regards,
Jamin
 
hi there,
I have a Master/Detail views. In the Detailview the Seletion is done via the SqlDataSource (calling an SP with the parameters) while the Update is done in VB code.
My problem is that I'm mixing things as the update done in vb is ok but I have an error stating: "Updating is not supported by data source 'dsDvContacts' unless UpdateCommand is specified", my code is as follow:

<asp:DetailsView ID="dvChildren" runat="server" DataSourceID="dsDvParents" AutoGenerateRows="False"
DataKeyNames="ID" BackColor="White" BorderColor="#DEDFDE"
BorderStyle="None" BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical" >
<Fields>
....
</Fields>
</asp:DetailsView>

<asp:SqlDataSource ID="dsDvParents" runat="server" ConnectionString="<%$ ConnectionStrings:myCS %>"
SelectCommand="SelectDetailsByParentID"
SelectCommandType="StoredProcedure" >
<SelectParameters>
<asp:ControlParameter ControlID="lvParents" Name="ParentID" PropertyName="SelectedValue" Type="Int32" DefaultValue="-1" />
<asp:parameter DefaultValue="0" Direction="InputOutput" Name="IDENTITY" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>

tia
 
Look for examples on how to use the command objects, or Microsoft's DataAccess Blocks.
 
I was looking for examples on command objects, since the Select part was done through <asp:SqlDatasource> while the update was made in vb.net code. Wanted to "homogenize" the whole so I found this approach:
Dim myDV as DataView
myDV = Ctype(SqlDataSource1.Select(DataSourceSelectArgument.Empty) ,dataview)

If you have a better proposal, welcome !
cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top