Click here to Skip to main content
16,018,294 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
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();




            }
          
        }


    }
i want to define ParameterId as Datakey value for this image button ...how i can i difine..syntax..
as we r defining like this
C#
string ParameterId = Convert.ToString(grdcareplan.DataKeys[e.RowIndex].Value);

in edit delete functionality of gridview..
Posted
Updated 5-Jan-13 1:08am
v4
Comments
AshishChaudha 5-Jan-13 7:09am    
didnt understand the question, please elaborate your question.

1 solution

XML
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);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900