Infragistics WebDataGrid的使用

http://community.infragistics.com/aspnet/forums/default.aspx(官网讨论区)

 

1 前台

 

   在使用infragistics控件的时候需要首先添加ScriptManager控件,否则使用会出错

  

   WebDataGrid控件的前台代码

   <ig:WebDataGrid ID="igwebdgManufacture" runat="server" AutoGenerateColumns="False"
            Height="350px" Width="100%" DataKeyFields="ManufacturerID" EnableAjax="False"
            EnableDataViewState="true"
            oninitializerow="igwebdgManufacture_InitializeRow"
            onitemcommand="igwebdgManufacture_ItemCommand" >
            <Columns>
                <ig:BoundDataField DataFieldName="ManufacturerID" Key="ManufacturerID">
                    <Header Text="ID" />
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="ManufacturerName" Key="ManufacturerName">
                    <Header Text="制造商名称" />
                </ig:BoundDataField>
                <ig:BoundDataField DataFieldName="CreationTime" Key="CreationTime">
                    <Header Text="创建时间" />
                </ig:BoundDataField>
                <ig:TemplateDataField Key="Operation">
                    <Header Text="Operation" />
                    <ItemTemplate>
                        <asp:LinkButton ID="lbtn_Edit_" runat="server" CommandName="Edit" CommandArgument='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "ManufacturerID") %>'>Edit</asp:LinkButton>&nbsp;&nbsp;
                        <asp:LinkButton ID="lbtn_Del_" runat="server" CommandName="Del" CommandArgument='<%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "ManufacturerID") %>'
                            OnClientClick="javascript:return confirm('你确定要删除此数据吗?');">Del</asp:LinkButton>
                    </ItemTemplate>
                </ig:TemplateDataField>
            </Columns>
            <Behaviors>
                <ig:Paging PagerAppearance="Bottom" PageSize="20" Enabled="true" />
            </Behaviors>
        </ig:WebDataGrid>

 

        使用控件获取值的时候使用:

        <%# DataBinder.Eval(((Infragistics.Web.UI.TemplateContainer)Container).DataItem, "ManufacturerID") %>

 

2 后台

 

        /// <summary>
        /// 数据显示自动编号
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void igwebdgManufacture_InitializeRow(object sender, Infragistics.Web.UI.GridControls.RowEventArgs e)
        {
            if (e.Row.Index != -1)
            {
                int id = e.Row.Index + 1;
                e.Row.Items[0].Text = id.ToString();
            }
        }

       
        protected void igwebdgManufacture_ItemCommand(object sender,

Infragistics.Web.UI.GridControls.HandleCommandEventArgs e)
        {
            bool blnDel = false;
            if (e.CommandName == "Edit")
            {
                Response.Redirect("ManufacturerSave.aspx?ManufacturerID=" + e.CommandArgument.ToString());
            }
            else if (e.CommandName == "Del")
            {
                //blnDel = ;
                if (blnDel == false)
                {

                }
                else
                {

                }

            }
        }
    }

 

     ItemCommand的使用类似于gridview的RowCommand方法。(偶是这么理解的)使用ItemCommand方法的时候,前台必须设置EnableDataViewState属性为true。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值