- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我正在尝试从 ButtonField(数据绑定(bind))访问文本,但如果我将它作为 TableCell 引用,则无法获取文本。我该怎么做才能获得它的文本?
标记:
<asp:GridView ID="gvClass" runat="server" CssClass="grid" HeaderStyle-Font-Bold="true" Width="100%" OnSelectedIndexChanged="gvClass_SelectedIndexChanged" DataKeyNames="ClassID" AutoGenerateColumns="False" OnPageIndexChanging="gvClass_PageIndexChanging">
<HeaderStyle Font-Bold="True" />
<Columns>
<asp:ButtonField DataTextField="ClassID" HeaderText="Class ID" CommandName="Select" />
<asp:BoundField DataField="CourseName" HeaderText="Course Name" />
<asp:BoundField DataField="WarehouseName" DataFormatString="Warehouse" HeaderText="Warehouse" />
<asp:BoundField DataField="TrainerNames" HeaderText="Trainer(s)" />
<asp:BoundField DataField="StartTime" HeaderText="Start Time" />
<asp:BoundField DataField="Duration" HeaderText="Duration" />
<asp:BoundField DataField="Course Category" HeaderText="Course Category" />
<asp:BoundField DataField="Comment" HeaderText="Comment" />
</Columns>
<EmptyDataTemplate>
<span class="italic grey">No Record Found</span>
</EmptyDataTemplate>
</asp:GridView>
代码隐藏:
foreach (GridViewRow gvr in gvClass.Rows)
{
foreach (TableCell tc in gvr.Cells)
{
stringToAppend = tc.Text;
sb.Append(PRTL_UtilityPackage.FormatHtmlCharacters(stringToAppend) + " \t");
}
sb.Append("\\n");
}
foreach(gvr.Cells 中的 TableCell tc)在查看 ButtonField 时出现一个空字符串。
最佳答案
您仍然可以使用 tablecell 方法:
protected void myGridView_DataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
// You may have to play with the index of the control
// I have found that often a GridView will place a
// Literal control as Control[0] and the LinkButton
// as Control[1]. Once you find the index, it won't
// change.
LinkButton btn = (LinkButton)e.Row.Cells[0].Controls[1];
string text = btn.Text;
}
}
关于c# - 如果 ButtonFields 文本不被视为 TableCell,我如何访问它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4760465/
我在使用 ButtonField 发出行命令时遇到问题。 当我单击 ButtonField 中的 ImageButton 时,IsPostBack 为 false 我的理解是 GridView 的 B
我对 GridView 中 ButtonField(图像类型)背后的命令有疑问。 有一个名为 gvIngevuld 的 GridView,我在其中显示数据行和 1 个 ButtonField 行。现在
我想在单击 gridview 的 ButtonField 时执行 JavaScript 函数 因为没有onclick 或onclient click present 最佳答案 处理 RowDat
我正在开发一个黑莓应用程序。当用户按下一个按钮并按住它 2 秒时,我想在同一屏幕上触发任何操作。 任何方式 谢谢 最佳答案 这是您在非常非正式的伪代码中需要做的: When (click de
我有这个 GridView,它填充了 Page_Load: protected void Page_Load(object sender, EventArgs e) { if (!Page.IsP
如何在 BlackBerry 中将图像设置为 ButtonField 的背景? 最佳答案 其他方式是扩展ButtonField并在油漆上绘制图像: class BitmapButtonField ex
我在黑莓中创建了一个 CustomButtonField,我可以使用它来设置我们自己的按钮高度和宽度。我面临的问题是我不知道如何在按钮的中心显示标签。 最佳答案 您可以使用paint方法修改标签布局、
在 BlackBerry 中,如何在点击事件期间更改 ButtonField 背景颜色?例如,对于长按,背景颜色需要改变。对我来说,它采用默认颜色蓝色。怎么改? 这是我们的自定义按钮字段。但它显示按钮
我正在尝试从 ButtonField(数据绑定(bind))访问文本,但如果我将它作为 TableCell 引用,则无法获取文本。我该怎么做才能获得它的文本? 标记:
我正在处理 GridView 中的 ButtonField 列,其 RowCommand 处理程序不会在以下生命周期中触发。 这是网络上的一个常见问题 - 除其他外 - this SO post帮助我
我想在 asp:buttonfield 上应用 javascript,当点击按钮时显示消息。喜欢删除按钮确认消息。 最佳答案 asp:ButtonField> 标记没有 OnClientClick。
我有一个非常简单的 ASP.NET Web 表单,看起来有点像下面这样: (在PageLoad中我调用了grid
我有一个 GridView Asp.net 应用程序中的控件,具有 的 type="image"和 CommandName="Delete" . 有没有办法在到达 OnRowDelete 之前执行一段
我有一个 GridView 显示人员记录。我想根据基础记录的某些属性有条件地显示 CommandField 或 ButtonField 。这个想法是只允许对特定的人执行命令。 执行此操作的最佳方法是什
我在页面顶部有一个 JavaScript 函数,我希望它从 gridview 中的 ButtonField (类型:图像)调用,但我不能,因为 OnClick 不可用。怎么做 ? 功能: fun
我已经为网上商店类型的项目编写了 ASP 代码。有一种方法可以将 ProductID 添加到 cookie 中,并将产品数量加 1。另一种方法是读取cookie,将cookie转化为数据表,放到gri
我有一个 gridview 行,单击时必须执行回发 A,该行中有一个按钮字段,单击时必须执行回发 B。问题是,当我单击按钮字段时,event1 和 event2 都会被触发。下面是代码。 protec
我的 GridView 中有几个 ButtonField,对应于“编辑”和“删除”。 我想在代码中使用 JQuery 来显示删除确认弹出窗口。 ButtonField 在 HTML 中呈现为“a hr
我创建了一个 ButtonField 和一个 BitmapField 像.. public class MyCanvas extends MainScreen implements FieldCh
我是一名优秀的程序员,十分优秀!