本文介绍了如何在图像按钮单击中定义datakey值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void Imgbtnsave_Click(object sender, ImageClickEventArgs e)
{
MySqlConnection StrConnection = null;
MySqlCommand StrCommand = null;
try
{
StrConnection = new MySqlConnection();
StrConnection.ConnectionString = StrConn;
StrConnection.Open();
StrCommand = new MySqlCommand();
StrCommand.CommandType = CommandType.StoredProcedure;
StrCommand.CommandText = "Select_LastDate_Result";
StrCommand.Connection = StrConnection;
StrCommand.Parameters.AddWithValue("_DiseaseId", ddlselectdisease.SelectedValue);
StrCommand.Parameters.AddWithValue("_Branch_Id", 1);
StrCommand.Parameters.AddWithValue("_Tenant_Id", 1);
StrCommand.Parameters.AddWithValue("_Patient_Id", 1);
StrCommand.ExecuteNonQuery();
BindCarePlan();
}
catch (Exception ex)
{
obj.InfoEntry(DateTime.Now + " " + "BtnSave1_Click" + " " + "AccountBalance.aspx" + " " + ex.Message, "");
obj.InfoEntry(DateTime.Now + " " + ex.StackTrace, "");
Session["strerrormsg"] = DateTime.Now + " " + "BtnSave1_Click" + " " + "AccountBalance.aspx" + " " + ex.Message;
Session["strerrortrace"] = DateTime.Now + " " + ex.StackTrace;
Response.Redirect("ErrorPage.aspx");
}
finally
{
StrConnection.Close();
StrConnection.Dispose();
}
}
}
我想将ParameterId定义为此图像按钮的Datakey值...我怎么能想到... ...}
我们这样定义
i want to define ParameterId as Datakey value for this image button ...how i can i difine..syntax..
as we r defining like this
string ParameterId = Convert.ToString(grdcareplan.DataKeys[e.RowIndex].Value);
编辑删除gridview的功能..
in edit delete functionality of gridview..
推荐答案
Client Side
----------------
<asp:GridView ID="grdCreateEdit" runat="server" DataKeyNames="ParameterId">
</asp:GridView>
Server Side
----------------
int parameterId=0;
foreach (GridViewRow grdRow in grdCreateEdit.Rows)
{
int.TryParse(grdCreateEdit.DataKeys[grdRow.RowIndex].Values[0].ToString(), out parameterId);
}
这篇关于如何在图像按钮单击中定义datakey值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!