asp.net c#Gridview行点击功能 [英] asp.net c# Gridview row click function
问题描述
我在 sample.asp
页面上有 gridview1
。它有大约15行。我想要做的是:
如果我在gridview1中点击一行(比如第7行),它应该更新其他几行(比如第2,3行,4)在相同的网格视图中。在点击该行时,我想调用已存在于 sample.asp.cs
中的函数 UpdateOnClick()
>文件。这个函数应该改变同一个gridview中所需行的值。
我想在同一个gridview上更新其他几行 / p> 我该如何做到这一点? 您可以调用UpdateOnClick从OnRowCommand中,CommandEventArgs(大多数人称之为e)在其CommandArgument属性中给出了选定的行。 从这里可以遍历行来找到你要。无论如何这应该给你足够的副本和粘贴食物: I have If i click on a row (say row 7) in the gridview1, it should update a few other rows (say rows 2,3,4) in the same gridview. On clicking the row, I want to call the function I want to update a few other rows on the same gridview how can i achieve this? You can call the UpdateOnClick from the OnRowCommand, the CommandEventArgs (which most people call e) gives the selected row in its CommandArgument property. From this, you can iterate through the rows to find the ones you want. This should give you enough copy and paste food anyway:
这篇关于asp.net c#Gridview行点击功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
pre $ protected void GridView1_OnRowCommand(object sender,GridViewCommandEventArgs e)
{
int rownum = Convert.ToInt32(e.CommandArgument.ToString());
foreach(在sender.Rows中的GridViewRow行)
{
if(row.Cells [0] .Text ==a-value-)
{
//做某事......
}
}
}
gridview1
on sample.asp
page. It has about 15 rows. What i want to do is:UpdateOnClick()
that is already present in the sample.asp.cs
file. This function should change the values in the desired rows on the same gridview.protected void GridView1_OnRowCommand(object sender, GridViewCommandEventArgs e)
{
int rownum = Convert.ToInt32(e.CommandArgument.ToString());
foreach(GridViewRow row in sender.Rows)
{
if(row.Cells[0].Text == "a-value-")
{
// Do something....
}
}
}