I have the following C#
protected void sprint_availability_ItemDeleting(object sender, ListViewDeleteEventArgs e)
{
string sprintid = "";
Label lbl = (sprint_availability.Items[e.ItemIndex].FindControl("sprint_id_lbl")) as Label;
if (lbl != null)
sprintid = lbl.Text;
string projectid = "";
Label pid = (sprint_availability.Items[e.ItemIndex].FindControl("project_id_lbl")) as Label;
if (pid != null)
projectid = pid.Text;
string ConnectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection myConnection = new SqlConnection(ConnectionString);
myConnection.Open();
String query = "DELETE FROM sprints WHERE [sprint_id] = '" + sprintid + "'";
SqlCommand myCommand = new SqlCommand(query, myConnection);
myCommand.ExecuteNonQuery();
myConnection.Close();
Response.Redirect("project.aspx?project_id="+ pid);
}
The SQL Query works fine as it is deleting the row without any issue, however the redirect is redirecting to http://project.aspx?project_id=System.Web.UI.WebControls.Label
This is the section of the asp code which displays the label I am trying to call
<asp:Label Text='<%# Eval("project_id") %>' runat="server" ID="project_id_lbl" Visible="false"/><br />
pidis aLabel, you probably wantprojectidinstead:Response.Redirect("project.aspx?project_id="+ projectid);project_id="+ pid.Text);orproject_id="+ projectid);