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。

你可能感兴趣的:(JavaScript,server,object,制造,header,asp)