Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 获取GridView中的列名,该GridView在数据绑定行上具有动态列(透视查询)_C#_Asp.net_Gridview_Pivot - Fatal编程技术网

C# 获取GridView中的列名,该GridView在数据绑定行上具有动态列(透视查询)

C# 获取GridView中的列名,该GridView在数据绑定行上具有动态列(透视查询),c#,asp.net,gridview,pivot,C#,Asp.net,Gridview,Pivot,我正在使用SQL数据源生成Gridview。数据源有一个存储过程,该存储过程使用透视生成基于日期的列名。我想使每个单元格都可以单击(基于列中的文本),但在查找列名时遇到困难 我尝试了一些方法,如检查行[0]。理想情况下,我希望根据行的第一列和列标题将单元格的值传递给更新面板,但首先我需要知道我正在创建的单元格的列标题文本是什么 if (e.Row.RowType != DataControlRowType.Header) { string item = e.Row.Ce

我正在使用SQL数据源生成Gridview。数据源有一个存储过程,该存储过程使用透视生成基于日期的列名。我想使每个单元格都可以单击(基于列中的文本),但在查找列名时遇到困难

我尝试了一些方法,如检查行[0]。理想情况下,我希望根据行的第一列和列标题将单元格的值传递给更新面板,但首先我需要知道我正在创建的单元格的列标题文本是什么

if (e.Row.RowType != DataControlRowType.Header)
    {

        string item = e.Row.Cells[0].Text;
        string column;

        for (int j = 0; j < e.Row.Cells.Count; j++)
        {
            column = GridView1.HeaderRow.Cells[j].Text;

            if (j >= 3)
            {


                e.Row.Cells[j].Font.Italic = true;
                e.Row.Cells[j].Text = e.Row.Cells[j].Text.Replace(".00", "");

                //if (GridView1.HeaderRow.Cells[j].Text.Substring(0,3) == "SKU")
                //{

                    e.Row.Cells[j].Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
                    e.Row.Cells[j].Attributes["onmouseout"] = "this.style.textDecoration='none';";
                    e.Row.Cells[j].ToolTip = "Click to select cell";
                    e.Row.Cells[j].Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
                //}
if(e.Row.RowType!=DataControlRowType.Header)
{
字符串项=e.Row.Cells[0]。文本;
字符串列;
对于(int j=0;j=3)
{
e、 Row.Cells[j].Font.Italic=true;
e、 Row.Cells[j].Text=e.Row.Cells[j].Text.Replace(“.00”,”);
//if(GridView1.HeaderRow.Cells[j].Text.Substring(0,3)=“SKU”)
//{
e、 Row.Cells[j].Attributes[“onmouseover”]=“this.style.cursor='pointer';this.style.textDecoration='underline';”;
e、 Row.Cells[j].Attributes[“onmouseout”]=“this.style.textDecoration='none';”;
e、 Row.Cells[j].ToolTip=“单击以选择单元格”;
e、 Row.Cells[j].Attributes[“onclick”]=this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1,“Select$”+e.Row.RowIndex);
//}

如果要在HTML代码中使用该值,可以执行以下操作:

     if (String.Equals(((VALUETYPE)e.Row.FindControl("IDCONTROLHTML")).Value.ToString(), "SOMEVALUE"))

希望这能起作用,伙计!!

你用哪一个事件来做这件事???OnRowDataBound(GridView1\u DataBound(对象发送者,GridViewRowEventArgs e))