GridView
asp.netを使用して、フロントエンドでSQLを使用してバインドしています。button_Click の前に、バインドされているデータベース テーブルの値GridView
がリセットされていることを確認しましたがGridView
、button_Click の後に反映されていません。
これが私のaspコードですGridView
:
<Columns>
<asp:BoundField DataField="Profiles" HeaderText="Profiles" ReadOnly="true" SortExpression="Profiles" />
<asp:BoundField DataField="Location_Profile" HeaderText="Location_Profile" SortExpression="Location_Profile" />
</Columns>
データソースの ASP コードは次のとおりです。
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:TouchPadConnectionString %>"
InsertCommand="INSERT INTO [Loc_Pro_Grid] ([Profiles], [Location_Profile]) VALUES (@Profiles, @Location_Profile)"
SelectCommand="SELECT * FROM [Loc_Pro_Grid]"
UpdateCommand="UPDATE Loc_Pro_Grid SET Location_Profile = @Location_Profile WHERE (Profiles = @Profiles)">
<InsertParameters>
<asp:Parameter Name="Profiles" Type="String" />
<asp:Parameter Name="Location_Profile" Type="Int32" />
</InsertParameters>
<UpdateParameters>
<asp:Parameter Name="Location_Profile" />
<asp:Parameter Name="Profiles" />
</UpdateParameters>
</asp:SqlDataSource>
私の .cs コードは次のとおりです。
protected void Save_Click(object sender, EventArgs e)
{
// I am doing some operations here then I am resetting the table as below
com = new SqlCommand("UPDATE Loc_Pro_Grid SET Location_Profile = 0 WHERE Profiles='" + ListBox1.Items[i].ToString() + "' ", con);
}
con.Open();
com.ExecuteNonQuery();
con.Close();