我总是得到一个空值的文本框从网格。下面是我的点击事件代码:
foreach (GridRecord row in wdgTroubleshootCreateEdit.Rows)
{
int workflowCATParameterId = Convert.ToInt32(row.Items[0].Value);
TextBox workflowCATParameterValue =
(TextBox)row.Items[value].FindControl("txtWorkflowCATParameterValue");
workflowCATParameterValue.text
总是null
我使用最新的服务版本11.2。我试着:
protected void Button2_Click(object sender, EventArgs e)
{
TextBox text = WebDataGrid1.Rows[0].Items[0].FindControl("TextBox1") as TextBox;
var rrr = text.Text;
}
,它工作得很好:)我的网格被称为WebDataGrid1和第一列被模板化包含TextBox命名为Text:
<ig:WebDataGrid ID="WebDataGrid1" runat="server" Height="350px" Width="400px">
<Columns>
<ig:TemplateDataField Key="TemplateField_0">
<header text="TemplateField_0" />
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ItemTemplate>
</ig:TemplateDataField>
</Columns>
<Behaviors>
<ig:EditingCore>
<behaviors>
<ig:CellEditing>
</ig:CellEditing>
</behaviors>
</ig:EditingCore>
<ig:Activation>
</ig:Activation>
</Behaviors>
<Templates>
<ig:ItemTemplate ID="WebDataGrid1Template1" runat="server"
TemplateID="Template1">
</ig:ItemTemplate>
</Templates>
</ig:WebDataGrid>
我用ie9测试了一下:)
通过javascript你可以这样做:
function OnExitedEditMode(sender,e){
var row = e.getCell().get_row();
var text = row.get_cellByColumnKey("YourDataKey").get_value();
....
}
在你的WebDataGrid中你需要输入这个:
<Behaviors>
<ig:EditingCore>
<Behaviors>
<ig:CellEditing EditModeActions-MouseClick="Single">
<ColumnSettings>
...
</ColumnSettings>
<CellEditingClientEvents ExitedEditMode="OnExitedEditMode" />
</ig:CellEditing>
</Behaviors>
</ig:EditingCore>
</Behaviors>