0

我有充满适配器的 GridView:

OracleDataAdapter adapter = new OracleDataAdapter();
DataTable tableD = new DataTable();
adapter.SelectCommand = oracleCom;
adapter.Fill(tableD);
tableResults.DataSource = tableD.AsDataView();
tableResults.DataBind();

tableResults - 它是一个 GridView。我添加了在 GridView 中更改数据的功能:

tableResults.AutoGenerateEditButton = true;
tableResults.RowEditing += new GridViewEditEventHandler(tableResults_RowEditing);
tableResults.RowUpdating += new GridViewUpdateEventHandler(tableResults_RowUpdating);
tableResults.RowCancelingEdit += new GridViewCancelEditEventHandler(tableResults_RowCancelingEdit);

现在,从这里: 在此处输入图像描述

当用户推送编辑链接时,他会看到: 在此处输入图像描述

如何在空字段中显示当前值?

这是加法:

<asp:GridView ID="tableResults" runat="server" DataMember="Table"
                EnableModelValidation="True" CssClass = "GridViewStyle" 
                OnRowDeleting = "dataViewRowDeleting" AutoGenerateDeleteButton="True">
               <HeaderStyle CssClass = "GridViewHeaderStyle" />
               <RowStyle CssClass = "GridViewRowStyle"/>    
               <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HyperLink runat="server" Text="Скачать объект" NavigateUrl='<%#"objects/" + Eval("Идентификатор") %>'></asp:HyperLink>
                    </ItemTemplate>    
                </asp:TemplateField>
               </Columns>           
            </asp:GridView>
4

1 回答 1

2

您只需单击编辑,但您还必须重新绑定您的网格视图只需在 gridview RowEditing 事件上再次绑定您的网格视图,就像这样......

protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
    GridView1.EditIndex = e.NewEditIndex;
    bindGridView1();
}

试试这个,这绝对会帮助你。如果您仍然面临任何问题,而不是在此处描述您的问题...

于 2012-11-12T03:47:14.847 回答