- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
这是我对 GridView 的标记。
<Columns>
<asp:TemplateField HeaderText="Customer Name">
<ItemTemplate>
<asp:Label ID="lblname" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Customer.Name")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="PickUpPoint">
<ItemTemplate>
<asp:Label ID="lblPickUpPoint" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Pickuppoint")%>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
我有一个按钮,用于将值存储在 excel 对象的工作表单元格中。
for (int i = 0; i < GridView2.Rows.Count; i++)
{
for (int j = 0; j < GridView2.Rows[i].Cells.Count; j++)
{
xlWorkSheet.Cells[i + 1, j + 1] = GridView2.Rows[i].Cells[j].Text;
}
}
如何获取 GridView 的值并将其存储在工作表中,因为 GridView2.Rows[i].Cells[j]
.Text 返回空字符串。
最佳答案
您缺少类型转换。这样做——
Label name = (Label)GridView2.Rows[i].Cells[j].FindControl("lblname");
xlWorkSheet.Cells[i + 1, j + 1] = name.Text;
Update- 如果您可以将标签命名为 Label0 和 Label1,那么在第二个 for 循环中-
for (int j = 0; j < GridView2.Rows[i].Cells.Count; j++)
{
Label xyz = (Label)GridView2.Rows[i].Cells[j].FindControl("Label"+j);
xlWorkSheet.Cells[i + 1, j + 1] = xyz.Text;
}
对于标题文本 - string hText = GridView2.HeaderRow.Cells[您的列号].Text;
关于c# - 如何从 GridView 中的模板字段中获取值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13795468/
这个问题在这里已经有了答案: final keyword in method parameters [duplicate] (9 个回答) 关闭 8 年前。 在此示例中,声明 Object fina
我的目标:是通过我的函数更新字段获取选定值并使用函数输出值运行它。 问题:当我从列表中选择值时,它不会触发函数,也不会更新字段。 感谢您的帮助。 HTML 12 14 16 18 20 22 24
我有一本具有这种形式的字典: myDict = {'foo': bar, 'foobar baz': qux} 现在,我想拆分字典键中的空格,使其成为下一个键并获取值(重复)。 myDictRev1
vector a; vector b; int temp_holder; cout > temp_holder) a.push_back(temp_holder); cout > temp_h
Java 的开发过程中免不了与 Date 类型纠缠,准备总结一下项目经常使用的日期相关操作,JDK 版本 1.7,如果能够帮助大家节约那么几分钟起身活动一下,去泡杯咖啡,便是极好的,嘿嘿。当然,我
我正在使用 jquery ui 日期选择器来获取 fromDate 和 toDate 以下是from日期的代码 $("#from_date").datepicker({
我是一名优秀的程序员,十分优秀!