Update gridview issue

  • Thread starter Thread starter egsdar
  • Start date Start date
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.
 
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.
 
When I hit the update link and then try to save something is not saving
anythig at all.
 
Back
Top