试图在Radgrid插入过程中获得控制
我有一个简单的网格来显示一些评论。这是GridBoundColumn;
<telerik:GridBoundColumn
DataField="Comment"
UniqueName="Comment"
HeaderText="Comment"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-Width="170px"
HeaderStyle-Width="105px">
</telerik:GridBoundColumn>
我已经捕获了OninsertCommand,我需要为评论字段获得新值。
protected void rgvComments_OnInsertCommand(object sender, GridCommandEventArgs e)
{
clsShortageComment thisClass = new clsShortageComment();
GridEditableItem editableItem = (GridEditableItem)e.Item;
Hashtable values = new Hashtable();
editableItem.ExtractValues(values);
RadTextBox theBox = editableItem.FindControl("Comment") as RadTextBox;
thisClass.Comment = theBox.Text;
thisClass.Employee = rtbEmployee.Text;
thisClass.Active = true;
thisClass.MaterialReq = Convert.ToInt32(rlbMaterial.SelectedItem.Value);
thisClass.InsertRecord();
} // rgvcomments_oninsertcommand()...
问题是获取RadTextbox的FindControl出现null。我可以在哈希表中看到评论字段,但是如何获得值?
I have a simple grid to display some comments. Here is the GridBoundColumn;
<telerik:GridBoundColumn
DataField="Comment"
UniqueName="Comment"
HeaderText="Comment"
HeaderStyle-HorizontalAlign="Center"
ItemStyle-Width="170px"
HeaderStyle-Width="105px">
</telerik:GridBoundColumn>
I've captured the OnInsertCommand and I need to get the new value for the Comment field.
protected void rgvComments_OnInsertCommand(object sender, GridCommandEventArgs e)
{
clsShortageComment thisClass = new clsShortageComment();
GridEditableItem editableItem = (GridEditableItem)e.Item;
Hashtable values = new Hashtable();
editableItem.ExtractValues(values);
RadTextBox theBox = editableItem.FindControl("Comment") as RadTextBox;
thisClass.Comment = theBox.Text;
thisClass.Employee = rtbEmployee.Text;
thisClass.Active = true;
thisClass.MaterialReq = Convert.ToInt32(rlbMaterial.SelectedItem.Value);
thisClass.InsertRecord();
} // rgvComments_OnInsertCommand() ...
The problem is the FindControl to get the RadTextBox comes up null. I can see the Comment field in the hash table, but how do I get the value?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了正确的语法。我将在此处发布,以防将来有人遇到这个问题。
I found the right syntax. I'm posting it here in case someone runs across this problem in the future.