GridView中的按钮事件没有响应。C#
我在网格视图中的按钮有问题。它没有响应我的GridView中的按钮事件没有响应。C#,c#,asp.net,gridview,datagridviewbuttoncolumn,C#,Asp.net,Gridview,Datagridviewbuttoncolumn,我在网格视图中的按钮有问题。它没有响应我的响应.Redirect(“secondHistory.aspx”)和我的控制台.WriteLine(“hih”)。下面是HTML代码 以下是必要时填充表的代码 protected void GridView1_SelectedIndexChanged(object sender, EventArgs e) { DataTable dt = new DataTable(); dt.Columns.Add("Exce
响应.Redirect(“secondHistory.aspx”)
和我的控制台.WriteLine(“hih”)
。下面是HTML代码
以下是必要时填充表的代码
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("ExcelID", typeof(int));
dt.Columns.Add("excelName", typeof(string));
dt.Columns.Add("excelDescription", typeof(string));
dt.Columns.Add("date / time", typeof(string));
dt.Columns.Add("empID", typeof(int));
dt.Columns.Add("empName", typeof(string));
dt.Columns.Add("engID", typeof(int));
dt.Columns.Add("engName", typeof(string));
dt.Columns.Add("firstApproval", typeof(string));
dt.Columns.Add("secondApproval", typeof(string));
for(int i = 0; i < textfiles.Length; i++)
{
textList.Add(File.ReadAllText(textfiles[i]));
}
string[] textArray = textList.ToArray();
for (int i = 0; i < excelfiles.Length; i++)
{
dt.Rows.Add(i, excelfiles[i], textArray[i] , File.GetCreationTime(textfiles[i]), 837482, "*empName*", 917378, "*engName*", "Approved");
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
protectedvoid GridView1\u SelectedIndexChanged(对象发送方,事件参数e)
{
DataTable dt=新的DataTable();
添加(“ExcelID”,typeof(int));
添加(“excelName”,typeof(string));
添加(“excelDescription”,typeof(string));
添加(“日期/时间”,类型(字符串));
添加(“empID”,typeof(int));
添加(“empName”,typeof(string));
添加(“engID”,类型(int));
添加(“engName”,typeof(string));
dt.Columns.Add(“首次批准”,类型(字符串));
添加(“第二次批准”,类型为(字符串));
对于(int i=0;i
请帮忙,谢谢 你试过调试吗?它是否在处理程序中实际设置了正确的值?SelectedIndexChanged最初是否填充网格,或者是否有代码执行我们没有看到的操作?是的,SelectedIndexChanged是唯一填充网格的代码。没有任何其他代码填充它@Conradlotz测试了你的代码。它正常工作。它没有将我重定向到另一个页面,那么问题是什么@VDWWD
protected void GridView_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Accept")
{
// Retrieve the row index stored in the
// CommandArgument property.
int index = Convert.ToInt32(e.CommandArgument);
// Retrieve the row that contains the button
// from the Rows collection.
GridViewRow row = GridView1.Rows[index];
// Add code here to add the item to the shopping cart.
Console.WriteLine("hih");
Response.Redirect("secondHistory.aspx");
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
DataTable dt = new DataTable();
dt.Columns.Add("ExcelID", typeof(int));
dt.Columns.Add("excelName", typeof(string));
dt.Columns.Add("excelDescription", typeof(string));
dt.Columns.Add("date / time", typeof(string));
dt.Columns.Add("empID", typeof(int));
dt.Columns.Add("empName", typeof(string));
dt.Columns.Add("engID", typeof(int));
dt.Columns.Add("engName", typeof(string));
dt.Columns.Add("firstApproval", typeof(string));
dt.Columns.Add("secondApproval", typeof(string));
for(int i = 0; i < textfiles.Length; i++)
{
textList.Add(File.ReadAllText(textfiles[i]));
}
string[] textArray = textList.ToArray();
for (int i = 0; i < excelfiles.Length; i++)
{
dt.Rows.Add(i, excelfiles[i], textArray[i] , File.GetCreationTime(textfiles[i]), 837482, "*empName*", 917378, "*engName*", "Approved");
}
GridView1.DataSource = dt;
GridView1.DataBind();
}