Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
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
string ParameterId = Convert.ToString(grdcareplan.DataKeys[e.RowIndex].Value);
in edit delete functionality of gridview..
Posted 5-Jan-13 1:29am
ujali435
Edited 5-Jan-13 2:08am
v4
Comments
AshishChaudha at 5-Jan-13 7:09am
   
didnt understand the question, please elaborate your question.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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);
}
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 7,105
1 DamithSL 5,079
2 Maciej Los 4,866
3 Sergey Alexandrovich Kryukov 4,617
4 Kornfeld Eliyahu Peter 4,384


Advertise | Privacy | Mobile
Web02 | 2.8.141223.1 | Last Updated 5 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100