this question私はASP.NetのGridViewコントロール(私はC#を使用しています)の奇妙な動作について尋ねました。__doPostBackの正しいGridViewマークアップが表示されない
GridViewの各行には、「編集」と「削除」リンクがあります。たとえば、編集にはjavascript:__doPostBack('gvwServers','Edit$0')
が含まれています。サーバーは、誰かが0
の行を編集するためにクリックしたことを明らかにする予定です。gvwServers
です。
十分に適切です。編集リンクをクリックするとポストバックが取得され、編集ボタンが「更新」と「キャンセル」ボタンに置き換えられてGridViewが再描画されます。標準的な動作。 NOW - 'キャンセル'ボタンにはこのリンクがありますjavascript:__doPostBack('gvwServers','Cancel$0')
- 私は予期したとおりです。行0
のキャンセルはgvwServers
です。しかし、更新ボタンはjavascript:__doPostBack('gvwServers$ctl02$ctl00','')
です。これは意味をなさないと思われる。そして、これは私のルーチンが更新を処理しないようにする原因のように見えます。
ASPが正しいポストバック引数を出力しないのはなぜですか?
私のコードは上記のリンクから入手できます。
<asp:GridView ID="gvwServers" runat="server" class="gvwServers"
AutoGenerateColumns="false" OnRowEditing="gvwServers_Edit"
onrowcancelingedit="gvwServers_Cancelling" onrowdeleting="gvwServers_Deleting"
onrowupdated="gvwServers_Updated" onrowupdating="gvwServers_Updating"
AutoGenerateEditButton=true AutoGenerateDeleteButton=true>
<columns>
<asp:CommandField ShowEditButton="true" />
<asp:CommandField ShowDeleteButton="true" />
<asp:BoundField DataField="intServerID" visible="false" />
<asp:TemplateField HeaderText = "Server Name">
<ItemTemplate>
<asp:Label ID="lblServerName" runat="server" Text='<%# Bind("txtName") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtServerName_Edit" runat="server" Text='<%# Bind("txtName") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Key">
<ItemTemplate>
<asp:Label ID="lblAppKey" runat="server" Text='<%# Bind("txtApplicationKey") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtAppKey_Edit" runat="server" Text='<%# Bind("txtApplicationKey") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Connection String">
<ItemTemplate>
<asp:Label ID="lblConnString" runat="server" Text='************'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox runat="server" ID="txtConnString_Edit" Width="300px" Height="100px" Text='<%# Bind("txtConnectionString")%>' TextMode="MultiLine" ></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</columns>
</asp:GridView>
すべてのgridviewコードを表示できますか? (上のリンクは編集/削除のみを表示しています)簡単な見落としがあるかもしれません。 – Wil
@Wilマークアップで更新 –