Update gridview issue

E

egsdar

How can I solve this update issue with my gridview?



This is my code:


<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataSourceID="SqlDataProspecto" DataKeyNames="IdProspecto"
Style="position: static">
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:BoundField DataField="IdProspecto"
HeaderText="IdProspecto" InsertVisible="False"
ReadOnly="True" SortExpression="IdProspecto" />
<asp:BoundField DataField="Prospecto" HeaderText="Prospecto"
SortExpression="Prospecto" />
<asp:TemplateField HeaderText="Sector"
SortExpression="Descripcion">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSector"
DataTextField="Descripcion"
DataValueField="IdSector" SelectedValue='<%# Bind("IdSector") %>'
Style="position: static">
</asp:DropDownList><asp:SqlDataSource
ID="SqlDataSector" runat="server" ConnectionString="<%$
ConnectionStrings:SIPConnectionString %>"
SelectCommand="SELECT * FROM [Sector] ORDER BY
[Descripcion]"></asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("Descripcion") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Nicho" SortExpression="Nicho">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="SqlDataNicho" DataTextField="Descripcion"
DataValueField="IdNicho" SelectedValue='<%#
Bind("IdNicho") %>' Style="position: static">
</asp:DropDownList><asp:SqlDataSource
ID="SqlDataNicho" runat="server" ConnectionString="<%$
ConnectionStrings:SIPConnectionString %>"
SelectCommand="SELECT * FROM [Nicho] ORDER BY
[Descripcion]"></asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("Nicho") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataProspecto" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:SIPConnectionString %>"
DeleteCommand="DELETE FROM [Prospecto] WHERE [IdProspecto] =
@original_IdProspecto AND [Nombre] = @original_Nombre AND [IdSector] =
@original_IdSector AND [IdNicho] = @original_IdNicho"
InsertCommand="INSERT INTO [Prospecto] ([Nombre], [IdSector],
[IdNicho]) VALUES (@Nombre, @IdSector, @IdNicho)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT Prospecto.IdProspecto, Prospecto.Nombre AS Prospecto,
Sector.IdSector, Sector.Descripcion, Nicho.IdNicho, Nicho.Descripcion AS
Nicho FROM Prospecto INNER JOIN Sector ON Prospecto.IdSector =
Sector.IdSector INNER JOIN Nicho ON Prospecto.IdNicho = Nicho.IdNicho ORDER
BY Prospecto"
UpdateCommand="UPDATE [Prospecto] SET [Nombre] = @Nombre,
[IdSector] = @IdSector, [IdNicho] = @IdNicho WHERE [IdProspecto] =
@original_IdProspecto AND [Nombre] = @original_Nombre AND [IdSector] =
@original_IdSector AND [IdNicho] = @original_IdNicho">
<DeleteParameters>
<asp:parameter Name="original_IdProspecto" Type="Int16" />
<asp:parameter Name="original_Nombre" Type="String" />
<asp:parameter Name="original_IdSector" Type="Int16" />
<asp:parameter Name="original_IdNicho" Type="Int16" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="Nombre" Type="String" />
<asp:parameter Name="IdSector" Type="Int16" />
<asp:parameter Name="IdNicho" Type="Int16" />
<asp:parameter Name="original_IdProspecto" Type="Int16" />
<asp:parameter Name="original_Nombre" Type="String" />
<asp:parameter Name="original_IdSector" Type="Int16" />
<asp:parameter Name="original_IdNicho" Type="Int16" />
</UpdateParameters>
<InsertParameters>
<asp:parameter Name="Nombre" Type="String" />
<asp:parameter Name="IdSector" Type="Int16" />
<asp:parameter Name="IdNicho" Type="Int16" />
</InsertParameters>
</asp:SqlDataSource>



Thanks in advance for the support.
 
J

Jonathan Wood

Perhaps it would be helpful if you said what the issue was.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

egsdar said:
How can I solve this update issue with my gridview?



This is my code:


<asp:GridView ID="GridView1" runat="server" AllowSorting="True"
AutoGenerateColumns="False"
DataSourceID="SqlDataProspecto" DataKeyNames="IdProspecto"
Style="position: static">
<Columns>
<asp:CommandField ShowDeleteButton="True"
ShowEditButton="True" />
<asp:BoundField DataField="IdProspecto"
HeaderText="IdProspecto" InsertVisible="False"
ReadOnly="True" SortExpression="IdProspecto" />
<asp:BoundField DataField="Prospecto"
HeaderText="Prospecto"
SortExpression="Prospecto" />
<asp:TemplateField HeaderText="Sector"
SortExpression="Descripcion">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSector"
DataTextField="Descripcion"
DataValueField="IdSector" SelectedValue='<%# Bind("IdSector") %>'
Style="position: static">
</asp:DropDownList><asp:SqlDataSource
ID="SqlDataSector" runat="server" ConnectionString="<%$
ConnectionStrings:SIPConnectionString %>"
SelectCommand="SELECT * FROM [Sector] ORDER BY
[Descripcion]"></asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#
Bind("Descripcion") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Nicho"
SortExpression="Nicho">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server"
DataSourceID="SqlDataNicho" DataTextField="Descripcion"
DataValueField="IdNicho" SelectedValue='<%#
Bind("IdNicho") %>' Style="position: static">
</asp:DropDownList><asp:SqlDataSource
ID="SqlDataNicho" runat="server" ConnectionString="<%$
ConnectionStrings:SIPConnectionString %>"
SelectCommand="SELECT * FROM [Nicho] ORDER BY
[Descripcion]"></asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%#
Bind("Nicho") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataProspecto" runat="server"
ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:SIPConnectionString %>"
DeleteCommand="DELETE FROM [Prospecto] WHERE [IdProspecto] =
@original_IdProspecto AND [Nombre] = @original_Nombre AND [IdSector] =
@original_IdSector AND [IdNicho] = @original_IdNicho"
InsertCommand="INSERT INTO [Prospecto] ([Nombre], [IdSector],
[IdNicho]) VALUES (@Nombre, @IdSector, @IdNicho)"
OldValuesParameterFormatString="original_{0}"
SelectCommand="SELECT Prospecto.IdProspecto, Prospecto.Nombre AS
Prospecto,
Sector.IdSector, Sector.Descripcion, Nicho.IdNicho, Nicho.Descripcion AS
Nicho FROM Prospecto INNER JOIN Sector ON Prospecto.IdSector =
Sector.IdSector INNER JOIN Nicho ON Prospecto.IdNicho = Nicho.IdNicho
ORDER
BY Prospecto"
UpdateCommand="UPDATE [Prospecto] SET [Nombre] = @Nombre,
[IdSector] = @IdSector, [IdNicho] = @IdNicho WHERE [IdProspecto] =
@original_IdProspecto AND [Nombre] = @original_Nombre AND [IdSector] =
@original_IdSector AND [IdNicho] = @original_IdNicho">
<DeleteParameters>
<asp:parameter Name="original_IdProspecto" Type="Int16" />
<asp:parameter Name="original_Nombre" Type="String" />
<asp:parameter Name="original_IdSector" Type="Int16" />
<asp:parameter Name="original_IdNicho" Type="Int16" />
</DeleteParameters>
<UpdateParameters>
<asp:parameter Name="Nombre" Type="String" />
<asp:parameter Name="IdSector" Type="Int16" />
<asp:parameter Name="IdNicho" Type="Int16" />
<asp:parameter Name="original_IdProspecto" Type="Int16" />
<asp:parameter Name="original_Nombre" Type="String" />
<asp:parameter Name="original_IdSector" Type="Int16" />
<asp:parameter Name="original_IdNicho" Type="Int16" />
</UpdateParameters>
<InsertParameters>
<asp:parameter Name="Nombre" Type="String" />
<asp:parameter Name="IdSector" Type="Int16" />
<asp:parameter Name="IdNicho" Type="Int16" />
</InsertParameters>
</asp:SqlDataSource>



Thanks in advance for the support.
 
E

egsdar

When I hit the update link and then try to save something is not saving
anythig at all.
 

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

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top