asp.net自定义gridview用户控件 [英] asp.net custom gridview user control

查看:168
本文介绍了asp.net自定义gridview用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,每个人都非常使用他的项目中的网格视图控件,至少我是这样做的。



i为我的网格添加了一个很好的风格,我删除了边框和单元格间距等。

i还使用存储过程从我的数据库中绑定它。

i编写分页方法和页面索引更改方法等。



现在我想将它打包在一个用户控件中,以便在任何项目或页面中使用这个网格,

,因为它令人沮丧地在每个页面都做到这一点每个项目。



但是当我把它放在用户控件中时,我无法从html中创建新的列和模板字段。



hello , every body use the grid view control in his project extremely , at least i do so.

i put a nice style to my grid and i erased the borders and cell spacing etc .
i also bind it from my db with stored procedure .
i write the paging method and the page index changing method etc .

now i want to package it in a user control to use this grid in any project or page ,
because its to frustrating to make all of this at every page and every project .

but when i put it in a user control , i couldn't make a new columns and template field from the html .

<uc1:WebGrid  runat="server" ID="WebGrid" />
        <!-- i want to be able to do this -->
        <!-- 
            <columns>

            TODO

            <coulumns>
            -->

推荐答案

您无法在设计时从父页面更改用户控件的HTML。如果您需要在设计时在用户控件gridview中添加任何列,则需要直接在用户控件.ascx文件中进行。所有更改都将在您使用此用户控件的每个页面中显示。



只有这样才能在用户控件中添加新列Gridview是通过动态代码来实现的。请按照以下链接在Gridview中动态添加列



使用C#在ASP.Net中将Gridiv列添加到Gridview [ ^ ]
You can not make change in HTML of user control from Parent Page at desgin time. If you need to add any column in user control gridview at design time then you need to do it directly in user control .ascx file .All the changes you made will be visible in every page where you use this user control.

Only way you can add new columns in user control Gridview is through code behind dynamically. Please follow below link for dynamically adding columns in Gridview

Add Dynamiv Column to Gridview In ASP.Net Using C#[^]


这篇关于asp.net自定义gridview用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆