gridview如何获取行ID
后台代码protectedvoidGridView1_RowDeleting(objectsender,GridViewDeleteEventArgse){strings...
后台 代码
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string strsql2 = "delete from [User] where User_ID="
SqlConnection sqlconn = new SqlConnection(strcon);
sqlconn.Open();
SqlCommand sqlcmd2 = new SqlCommand(strsql2, sqlconn);
sqlcmd2.ExecuteNonQuery();
}
}
前台代码 <form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="User_ID" DataSourceID="User" RowHeaderColumn="User_ID"
PageSize="5" AllowPaging="True" AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True" AutoGenerateSelectButton="True"
BackColor="#FF6600" BorderColor="#66FF99" BorderWidth="2px"
EmptyDataText="没有数据" ForeColor="#FFFF66"
onrowdeleting="GridView1_RowDeleting">
<Columns>
<asp:BoundField DataField="User_ID" HeaderText="User_ID" InsertVisible="False"
ReadOnly="True" SortExpression="User_ID" />
<asp:BoundField DataField="UserName" HeaderText="UserName"
SortExpression="UserName" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:BoundField DataField="Birthday" HeaderText="Birthday"
SortExpression="Birthday" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="User" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
SelectCommand="SELECT * FROM [User]"></asp:SqlDataSource>
</div>
</form>
怎么获取ID的值 展开
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string strsql2 = "delete from [User] where User_ID="
SqlConnection sqlconn = new SqlConnection(strcon);
sqlconn.Open();
SqlCommand sqlcmd2 = new SqlCommand(strsql2, sqlconn);
sqlcmd2.ExecuteNonQuery();
}
}
前台代码 <form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="User_ID" DataSourceID="User" RowHeaderColumn="User_ID"
PageSize="5" AllowPaging="True" AutoGenerateDeleteButton="True"
AutoGenerateEditButton="True" AutoGenerateSelectButton="True"
BackColor="#FF6600" BorderColor="#66FF99" BorderWidth="2px"
EmptyDataText="没有数据" ForeColor="#FFFF66"
onrowdeleting="GridView1_RowDeleting">
<Columns>
<asp:BoundField DataField="User_ID" HeaderText="User_ID" InsertVisible="False"
ReadOnly="True" SortExpression="User_ID" />
<asp:BoundField DataField="UserName" HeaderText="UserName"
SortExpression="UserName" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="Address" HeaderText="Address"
SortExpression="Address" />
<asp:BoundField DataField="Birthday" HeaderText="Birthday"
SortExpression="Birthday" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="User" runat="server"
ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
SelectCommand="SELECT * FROM [User]"></asp:SqlDataSource>
</div>
</form>
怎么获取ID的值 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询