当我用鼠标选择Gridview的某行与某列交汇的CELL时,如何获取这个CELL对应的列的名称

解决方案 »

  1.   

    主要是事件确认当前在那一列,gv.colums[x].Text;
      

  2.   

    /// <summary>   
    4./// 保存   
    5./// </summary>   
    6.protected void btnBC_Click(object sender, EventArgs e)   
    7.{   
    8.    string save_cblJL = "";   
    9.    for (int i = 0; i < this.cblJL.Items.Count; i++)   
    10.    {   
    11.        if (this.cblJL.Items[i].Selected == true)   
    12.        {   
    13.            save_cblJL += this.cblJL.Items[i].Value + ",";   
    14.        }   
    15.    }   
    16.  
    17.    string[] save_Excel = save_cblJL.Split(',');   
    18.  
    19.    for (int j = 0; j < save_Excel.Length - 1;j++ )   
    20.    {   
    21.        if (save_Excel[j].Equals("全部记录"))   
    22.        {   
    23.            toExcelClk(gvwjdccx, 3);   
    24.        }   
    25.        else if (save_Excel[j].Equals("当前页"))   
    26.        {   
    27.            toExcelClk(gvwjdccx, 2);   
    28.        }   
    29.        else if (save_Excel[j].Equals("当前记录"))   
    30.        {   
    31.            toExcelClk(gvwjdccx, 1);   
    32.        }   
    33.    }   
    34.}  保存Excel代码: /// <summary>   
    4./// 保存   
    5./// </summary>   
    6.protected void btnBC_Click(object sender, EventArgs e)   
    7.{   
    8.    string save_cblJL = "";   
    9.    for (int i = 0; i < this.cblJL.Items.Count; i++)   
    10.    {   
    11.        if (this.cblJL.Items[i].Selected == true)   
    12.        {   
    13.            save_cblJL += this.cblJL.Items[i].Value + ",";   
    14.        }   
    15.    }   
    16.  
    17.    string[] save_Excel = save_cblJL.Split(',');   
    18.  
    19.    for (int j = 0; j < save_Excel.Length - 1;j++ )   
    20.    {   
    21.        if (save_Excel[j].Equals("全部记录"))   
    22.        {   
    23.            toExcelClk(gvwjdccx, 3);   
    24.        }   
    25.        else if (save_Excel[j].Equals("当前页"))   
    26.        {   
    27.            toExcelClk(gvwjdccx, 2);   
    28.        }   
    29.        else if (save_Excel[j].Equals("当前记录"))   
    30.        {   
    31.            toExcelClk(gvwjdccx, 1);   
    32.        }   
    33.    }   
    34.}  
    35.#endregion 保存