asked on
protected void jobbasket_Click(object sender, EventArgs e)
{
System.Data.SqlClient.SqlConnection objConn = new System.Data.SqlClient.SqlConnection();
objConn.ConnectionString = "";
objConn.Open();
string cusername = string.Empty;
string Jobidbasket = DataList2.DataKeys[0].ToString();
if (HttpContext.Current.Request.IsAuthenticated)
{
cusername = HttpContext.Current.User.Identity.Name;
}
else
{
cusername = null;
Response.Redirect("pleaseregister.aspx");
}
System.Data.SqlClient.SqlCommand objCmd = new System.Data.SqlClient.SqlCommand("SQLSP", objConn);
objCmd.CommandType = System.Data.CommandType.StoredProcedure;
System.Data.SqlClient.SqlParameter jobid = objCmd.Parameters.Add("@jobid", System.Data.SqlDbType.Int);
System.Data.SqlClient.SqlParameter cuser = objCmd.Parameters.Add("@currentuser", System.Data.SqlDbType.NVarChar);
jobid.Direction = System.Data.ParameterDirection.Input;
jobid.Value = Jobidbasket;
cuser.Direction = System.Data.ParameterDirection.Input;
cuser.Value = cusername;
try
{
objCmd.ExecuteNonQuery();
}
catch (SqlException ex)
{
string popupScript = "<script language='javascript'>" +
"window.alert('You have already added this job');" +
"</script>";
Page.RegisterStartupScript("PopUpScript", popupScript);
}
objConn.Close();
}
-------image button
<asp:ImageButton ID="imagebutton1" runat="server"
CommandArgument='<%# Bind("jobid") %>' CommandName="DetailsViewRedirect"
ImageUrl="Images/icn_jb_bsket.gif"
OnClick="jobbasket_Click" style="height: 16px" />