Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/81.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#函数中获取HTML表ID?_C#_Html - Fatal编程技术网

在C#函数中获取HTML表ID?

在C#函数中获取HTML表ID?,c#,html,C#,Html,在HTML页面中,我用ID=“week1”创建了一个表,在C#函数中,我使用它作为 week1.Rows.Add(TableCell); 我想在表ID中强制转换字符串。假设我有字符串 for(int i=0; i<5; i++) { String abc = "week" + i; /* How to do cast this string in table ID like above to add rows and cell in table but ab

在HTML页面中,我用ID=“week1”创建了一个表,在C#函数中,我使用它作为

week1.Rows.Add(TableCell);
我想在表ID中强制转换字符串。假设我有字符串

for(int i=0; i<5; i++)
{
  String abc = "week" + i;
   /*
     How to do cast this string in table ID
     like above to add rows and cell in table but above is hardcoded and I want
     to make this dynamic.
   */
}

for(int i=0;i确保.aspx中的表具有
runat=“server”
),然后,在代码隐藏中,只需执行以下操作即可

week1.ID

或者
week1.ClientID
(用于DOM中的完整ID)-您想要的任何一个。

确保.aspx中的表具有
runat=“server”
),然后,在您的代码隐藏中,您只需执行以下操作即可

week1.ID

或者
week1.ClientID
(用于DOM中的完整ID)-无论您想要哪个。

如果您的表位于面板中,您可以这样查找它们。请注意,ofc需要runat=server。我假设您在表单()中使用HtmlTable

for(int i=0;i<5;i++)
{
var table=(HtmlTable)pnlTables.FindControl(“周”+i);
如果(表!=null)
{
//收拾你的桌子
}
}

如果您的表位于面板中,您可以这样查找它们。请注意,ofc需要runat=server。我假设您在表单()中使用HtmlTable

for(int i=0;i<5;i++)
{
var table=(HtmlTable)pnlTables.FindControl(“周”+i);
如果(表!=null)
{
//收拾你的桌子
}
}

您的表应该具有runat=“server”属性。只有这样,您才能从代码隐藏中访问它。

您的表应该具有runat=“server”属性。只有这样,您才能从代码隐藏中访问它。

请您更清楚地解释您的问题,如果有错误,我不确定您收到的是什么错误。您的表应该具有属性
运行=“服务器”
然后您可以从codebehind操作您的表。您能更清楚地解释您的问题吗?如果有错误,我不确定您收到的是什么错误。您的表应该具有属性
runat=“server”"
然后您可以从codebehind操作您的表。我的HTML表位于简单的网页中,我希望通过编程访问它们的ID,以便我可以在函数中使用,并将一些行和列添加到特定的表中。@Yeronimo…上述函数是否适用于我的表???或者在上面的示例中pnlTables是什么?我的意思是l类似于您的aspx。将所有表放在一个面板中:
我的HTML表位于简单的网页中,我希望通过编程访问它们的ID,以便我可以在函数中使用,并将一些行和列添加到特定的表中。@Yeronimo…上面的函数是否适用于我的表???或者上面的示例中的pnlTables是什么?我的意思是lik在您的aspx中添加此项。将所有表放在一个面板中: