2

假设我有这个网格,

<telerik:RadGrid
    ...........................
    ...........................
    <FormTemplate>
            <asp:TextBox ID="txtDescription" runat="server" />
    </FormTemplate>
    ...........................
    ...........................
    ...........................

现在在后面的代码中,我需要 DataSource1_Updating 事件中的 txtDescription,

    protected void DataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e){

这是可能的吗?

4

1 回答 1

1

这是我解决此问题的方法。定义了一个 EditCommand,

    protected void RadGrid1_EditCommand(object sender, GridCommandEventArgs e)
    {
        ViewState["CurrentIndex"] = e.Item.ItemIndex;
    }

在我的事件中,

protected void DataSource1_Updating(object sender, SqlDataSourceCommandEventArgs e){

        var currentIndex = (int)ViewState["CurrentIndex"];
        var form = RadGrid1.Items[currentIndex].EditFormItem;
        var txtDescription= form.FindControl("txtDescription") as RadComboBox;
于 2013-04-18T12:21:24.200 回答