aspxgridview中获取焦点行的模板里的asptextbox中的值

 

 int count = ASPxGridView2.FocusedRowIndex;        
        string out_trade_no = ASPxGridView2.GetRowValues(count, "out_trade_no").ToString();

        DevExpress.Web.ASPxEditors.ASPxTextBox checkBox = (DevExpress.Web.ASPxEditors.ASPxTextBox)this.ASPxGridView2.FindRowCellTemplateControlByKey(out_trade_no, (GridViewDataColumn)this.ASPxGridView2.Columns["sendno"], "aspxtxt_sendno");            
        string pp=checkBox.Text;

 

 

 

在ASPxGridView中应用模板列,可以实现用不同的风格显示内容,同时也可以不需要增加命令列,每次只能单独修改一列的情况,比如如下图片所示:

 

1、定义模板列代码:

 <dx:GridViewDataColumn FieldName="Visible" Caption="显示" VisibleIndex="2" Visible="true" Width="10%">
                                                            <DataItemTemplate>
                                                                <dx:ASPxCheckBox ID="chkVisibleColumn" runat="server" Width="30px" Checked="true">
                                                                </dx:ASPxCheckBox>
                                                            </DataItemTemplate>
                                                        </dx:GridViewDataColumn>

2、使用C#给模板列赋值

ASPxCheckBox checkBox = (ASPxCheckBox)this.gridColumns.FindRowCellTemplateControlByKey(“Code”,
                    (GridViewDataColumn)this.gridColumns.Columns["Visible"], "chkVisibleColumn");
                checkBox.Checked = true;

 

3、从模板列中获得值

ASPxCheckBox checkBox = (ASPxCheckBox)this.gridColumns.FindRowCellTemplateControlByKey((“Code”,
                    (GridViewDataColumn)this.gridColumns.Columns["Visible"], "chkVisibleColumn");
boo isVisible =  checkBox.Checked;

 

4、注意:

ASPxGridView控件一定要设置KeyFieldName属性:

<dx:ASPxGridView ID="gridColumns" runat="server" ClientInstanceName="gridColumns"
                                                    Width="100%" KeyFieldName="ColumnName" AutoGenerateColumns="false">

 

 

 

posted @ 2012-09-13 18:59  小锋神  阅读(2945)  评论(1编辑  收藏  举报