Hello,
how can i copy a row using the context menu
--> i could not find the primaryID with javascript
Thanks Jens
My code:
aspx
...
ClientSideEvents ContextClick="ContentClick" />
...
js
function ContentClick(args) {
alert("Hi");
var kbnUrl = "default9.aspx/CopyAction"
var card = {
"PrimaryID": ???? <-- i cant get die Primary ID form the Row
};
$.ajax({
async: true,
type: "POST",
contentType: "application/json; charset=utf-8",
url: kbnUrl,
data: JSON.stringify(card),
dataType: "json",
success: function (res) {
alert("Prima!");
},
error: function (e) {
alert("error");
}
});
}
C#
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static object CopyAction(int PrimaryID)
{
SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
if (myConnection.State == ConnectionState.Closed)
{
myConnection.Open();
}
string updateQuery = "INSERT ... into ... WHERE tableID = PrimaryID";
SqlCommand UpdateCmd = new SqlCommand(updateQuery, myConnection);
UpdateCmd.Parameters.Add(new SqlParameter("@PrimaryID", SqlDbType.Int)).Value = PrimaryID;
UpdateCmd.ExecuteNonQuery();
var ID = PrimaryID;
return PrimaryID;
}