数据库表PK是多字段的。查询出来的数据用了翻页,首页可以得到指定行的值,但后几页都不行。
该表PK是CITY_CODE,CITY_NAME
//初始化
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
BindData();
}
}
private void BindData()
{
string strSql="SELECT CITY_CODE,CITY_NAME,CITY_AREA,STATE";
strSql=strSql+" FROM QU_TB_CITY_CODE ";
DataSet ds=xpk.oradata.OraSqlReData(strSql);
ViewState["PolicyDetails"]=ds;
this.dgDetails.DataSource=ds;
this.dgDetails.DataBind();
}
//翻页
private void dgDetails_PageIndexChanged(object source, System.Web.UI.WebControls.DataGridPageChangedEventArgs e)
{
dgDetails.CurrentPageIndex = e.NewPageIndex;
BindData();
}
//删除指定行
private void dgDetails_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
string strCITYCODE = dgDetails.DataKeys[e.Item.ItemIndex].ToString();
string strCITYNAME = ??
string strSQL = "DELETE FROM QU_TB_CITY_CODE WHERE CITY_CODE='"+strCITYCODE+"'";
try
{
oradata.OraSqlInData(strSQL);
}
catch (Exception exp)
{
Response.Write(oradata.getErrorMsg(exp.Message));
}
finally
{
BindData();
}
}
请问怎么得到我需要的主键值!!!