前台代码:
<asp:GridView ID="ClientGridview" runat="server" AutoGenerateColumns="false" DataKeyNames="ClientID"
Font-Size="Small" OnRowCommand="ClientGridview_RowCommand">
<Columns>
<asp:BoundField DataField="ClientID" HeaderText="客户ID" ReadOnly="true" />
<asp:BoundField DataField="ClientName" HeaderText="客户名" />
<asp:ButtonField CommandName="ShowTeam" HeaderText="团队信息" Text="团队信息" />
<asp:ButtonField CommandName="ClientInfo" HeaderText="详细信息" Text="详细信息" />
</Columns>
</asp:GridView>
后台代码:
有两种操作:1.查看DetailsView中的信息(CommandName=ClientInfo)
2.转向另一个页面(CommandName=ShowTeam)
protected void ClientGridview_RowCommand(object sender, GridViewCommandEventArgs e)
{
conn = ConfigurationManager.AppSettings["str"];
con = new SqlConnection(conn);
con.Open();
int index = Convert.ToInt32((string)e.CommandArgument);
int ClientID = Convert.ToInt32(ClientGridview.DataKeys[index].Value.ToString());
Session["ClientID"] = ClientID;
if ((string)e.CommandName == "ShowTeam")
Response.Redirect("SearchTeamInfo.aspx");
else
{
if ((string)e.CommandName == "ClientInfo")
{
da = new SqlDataAdapter("select * from client where ClientID='" + ClientID + "'", con);
ds = new DataSet();
da.Fill(ds, "Client");
ClientDetailsView.DataSource = ds;
ClientDetailsView.DataBind();
}
}
con.Close();
}
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/35413.html