日期:2014-05-17 浏览次数:20820 次
protected void shanchu_Click(object sender, GridViewDeleteEventArgs e)
{
if (int.Parse(GridView1.DataKeys[e.RowIndex][1].ToString()) < 1)
{
if (sqlhelper.ExecuteNonQuery("delete from dingdan where id='" + int.Parse(GridView1.DataKeys[e.RowIndex][1].ToString()) + "' and username='" + sessionok.returnsession("userid") + "'") == 1)
{
getdata(ViewState["sql"].ToString());
}
}
}
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowcommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField HeaderText="序号">
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" CommandName="btn" CommandArgument='<%#Eval("id") %>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Button bt = e.CommandSource as Button;
string id = bt.CommandArgument;//绑定的数据
switch (e.CommandName)
{
&