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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update not working on gridview

Status
Not open for further replies.

newbieAl

Programmer
Sep 10, 2007
21
US
When I hard code the values into the updatecommand then the gridview gets updated, but if I just have the parameters the gridview does not get updated. What could the issue be?

This updates the grid:
UpdateCommand="Update atable set [afield]='test', [bfield]='test' where [id]=@id"

This doesn't:
UpdateCommand="Update atable set [afield]=@afield, [bfield]=@bfield where [id]=@id"
(I've got the parameter values set up, but for some reason when I post them here they don't show up, even after removing brackets, etc)
 
Here is my Gridview code. In addition to gridview I have 2 dropdownlists and the filtering logic is on the page_load event one the code behind (VB).

<asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" BackColor="White" BorderColor="#999999" BorderStyle="None"
BorderWidth="1px" CellPadding="3" DataKeyNames="ID" DataSourceID="DATA"
GridLines="Vertical"
Font-Names="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd" >
<PagerSettings Position="TopAndBottom"
FirstPageText="First Page"
LastPageText="Last Page"
Mode="NumericFirstLast" >
</PagerSettings>

<FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
<Columns>
<asp:HyperLinkField DataNavigateUrlFields="ANOTHER_ID" DataNavigateUrlFormatString="test2.aspx?ANOTHER_ID={0}"
Text="View Record" />
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False"
ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="AFIELD" HeaderText="AFIELD" SortExpression="AFIELD" />
<asp:BoundField DataField="BFIELD" HeaderText="BFIELD" SortExpression="BFIELD" />
<asp:BoundField DataField="CFIELD" HeaderText="CFIELD" SortExpression="CFIELD" ReadOnly="True" />
<asp:BoundField DataField="DATE" HeaderText="DATE" SortExpression="DATE" ReadOnly="True" />
</Columns>
<RowStyle BackColor="#EEEEEE" ForeColor="Black" />
<EmptyDataTemplate>
No Records Found
</EmptyDataTemplate>
<SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="Gainsboro" />
</asp:GridView>
 
Where are you trying to update?

And please use [ignore]
Code:
[/ignore] tags around your code to make it easier to read.

Thanks,

Alex

[small]----signature below----[/small]
I'm pushing an elephant up the stairs

My Crummy Web Page
 
Within the SQLDATASOURCE (updatecommand) of the aspx page
 
I've resolved the issue. I've removed the page_load, dropdownlist logic and added a selectcommand under the sqldatasource, to do the filtering there. It works now.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top