Die .aspx-Datei:
Code: Select all
 
Search by Last Name:
 
Code: Select all
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text.RegularExpressions;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnDelete_OnClick(object sender, EventArgs e)
{
Button b = (Button)sender;
GridViewRow containingRow = (GridViewRow)b.NamingContainer;
String strEmail = containingRow.Cells[4].Text;
DataSource1.DeleteCommand = "DELETE FROM [CoursesTaken] WHERE [StudentID] = '" + strEmail + "'";
DataSource1.Delete();
DataSource1.DeleteCommand = "DELETE FROM [Students] WHERE [Email] = '" + strEmail + "'";
DataSource1.Delete();
StudentList.DataBind();
}
protected void btnEdit1_OnClick(object sender, EventArgs e)
{
Button b = (Button)sender;
GridViewRow containingRow = (GridViewRow)b.NamingContainer;
Session["Email"] = containingRow.Cells[4].Text;
Response.Redirect("~/StudentEdit.aspx");
}
protected void btnGo_OnClick(object sender, EventArgs e)
{
int i = 0;
foreach (GridViewRow rowItem in StudentList.Rows)
{
if (rowItem.Cells[0].Text.StartsWith(txtSearch.Text))
{
StudentList.SelectedIndex = i;
int intScrollTo = this.StudentList.SelectedIndex * (int)this.StudentList.RowStyle.Height.Value;
string strScript = "";
strScript += "var gridView = document.getElementById('" + this.StudentList.ClientID + "');\n";
strScript += "if (gridView != null && gridView.parentElement != null && gridView.parentElement.parentElement != null)\n";
strScript += " gridView.parentElement.parentElement.scrollTop = " + intScrollTo + ";\n";
ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "btnGo_OnClick", strScript, true);
break;
}
i++;
}
}
}
Kann jemand erklären, warum es nicht wie erwartet funktioniert?
Mobile version