protected void gvCarLendInfo_RowCommand(object sender, GridViewCommandEventArgs e)
{
Response.Redirect(string.Format("CarLendManage.aspx?ItemBH={0}", gvCarLendInfo.DataKeys[Convert.ToInt32(e.CommandArgument)]));
}gvCarLendInfo的DataKeys属性也是设置的了!!!
{
Response.Redirect(string.Format("CarLendManage.aspx?ItemBH={0}", gvCarLendInfo.DataKeys[Convert.ToInt32(e.CommandArgument)]));
}gvCarLendInfo的DataKeys属性也是设置的了!!!
这种写法不对一般是直接e.CommandArgument
在监控里看到这几个数据,大家看下是不是DataKeys拍[]的问题~
DataKeyNames {维数:[1]} string[]
[0] "BH" string- DataKeys {System.Web.UI.WebControls.DataKeyArray} System.Web.UI.WebControls.DataKeyArray
Count 0 int
IsReadOnly false bool
IsSynchronized false bool
+ SyncRoot {System.Web.UI.WebControls.DataKeyArray} object {System.Web.UI.WebControls.DataKeyArray}
<Columns>
<asp:ButtonField Text="编辑" ButtonType="Button">
<HeaderStyle BackColor="#0000C0" Font-Size="Smaller" />
<ItemStyle HorizontalAlign="Center" Wrap="False" />
</asp:ButtonField>
<asp:BoundField DataField="BH" HeaderText="编号">
<FooterStyle BackColor="#80FFFF" />
<HeaderStyle BackColor="#0000C0" BorderStyle="Dotted" BorderWidth="1px" />
<ItemStyle HorizontalAlign="Center" Wrap="False" />
</asp:BoundField>
{
SX_QCZLXXCJ biz = new SX_QCZLXXCJ();
t = biz.LastXUHAO();
gvCarLendInfo.DataSource = t;
gvCarLendInfo.DataBind();
}
试下这个:
protected void gvCarLendInfo_RowCommand(object sender, GridViewCommandEventArgs e)
{
Response.Redirect(string.Format("CarLendManage.aspx?ItemBH={0}",
((GridView)sender).DataKeys[Convert.ToInt32(e.CommandArgument)]));
}