GridView Update Button Not Displayed

G

Guest

Hi,

My GridView is bound to a DataTable and the GridView properties are set
as follows:
AutoGenerateColumns="true"
AutoGenerateEditButton="true"
AutoGenerateDeleteButton="true"

The Edit and Detete button are displayed but when the Edit button is
clicked, the Update/Cancel buttons are not displayed. Does anyone have any
ideas? The full GridView properties are below.

Thank you,

Scott

<asp:GridView ID="GenericTableMaintenanceGridView"
AutoGenerateColumns="true"
AutoGenerateEditButton="true"
AutoGenerateDeleteButton="true"
AutoGenerateSelectButton="false"
CellPadding="5"
CellSpacing="5"
runat="server">
<FooterStyle BackColor="#FFFFFF" ForeColor="#FFFFFF" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" ForeColor="#F7F7F7" Wrap="false" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C"
HorizontalAlign="Right" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
</asp:GridView>
 
G

Guest

Hi,

My GridView is bound to a DataTable and the GridView properties are set
as follows:
AutoGenerateColumns="true"
AutoGenerateEditButton="true"
AutoGenerateDeleteButton="true"

The Edit and Detete button are displayed but when the Edit button is
clicked, the Update/Cancel buttons are not displayed. Does anyone have any
ideas? The full GridView properties are below.

Thank you,

Scott

<asp:GridView ID="GenericTableMaintenanceGridView"
AutoGenerateColumns="true"
AutoGenerateEditButton="true"
AutoGenerateDeleteButton="true"
AutoGenerateSelectButton="false"
CellPadding="5"
CellSpacing="5"
runat="server">
<FooterStyle BackColor="#FFFFFF" ForeColor="#FFFFFF" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<SelectedRowStyle BackColor="#738A9C" ForeColor="#F7F7F7" Wrap="false" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C"
HorizontalAlign="Right" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
</asp:GridView>

It will not work without a data source control (such as a
SqlDataSource control).

To make it working, create a SqlDataSource

<asp:sqldatasource id="myDS"
selectcommand="..."
updatecommand="..."
connectionstring="..."
runat="server">
</asp:sqldatasource>

and assign it to the data grid

<asp:gridview id="GenericTableMaintenanceGridView"
datasourceid="myDS"

Hope it helps
 
G

Guest

It will not work without a data source control (such as a
SqlDataSource control).

To make it working, create a SqlDataSource

<asp:sqldatasource id="myDS"
selectcommand="..."
updatecommand="..."
connectionstring="..."
runat="server">
</asp:sqldatasource>

and assign it to the data grid

<asp:gridview id="GenericTableMaintenanceGridView"
datasourceid="myDS"

Hope it helps- Hide quoted text -

- Show quoted text -

you can also use the data binding in the code-behind. In this case you
should use the OnEditCommand and the EditItemIndex property

here's some example (taken from a datagrid control)

<asp:gridview ...
OnEditCommand="DataGrid1_Edit"
OnCancelCommand="DataGrid1_Cancel"
OnUpdateCommand="DataGrid1_Update"
....

Public Sub DataGrid1_Edit(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
DataGrid1.EditItemIndex = E.Item.ItemIndex
DataGrid1.DataSource = ...
DataGrid1.DataBind()
End Sub
 

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,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top