Click here to Skip to main content
16,016,605 members
Please Sign up or sign in to vote.
2.00/5 (1 vote)
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 .

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

            TODO

            <coulumns>
            -->
Posted
Updated 9-Aug-13 16:28pm
v3
Comments
Manikandan Sekar 9-Aug-13 3:51am    
So what have you tried...?
Post your snippet and tell where you stuck and where you need help.
Without complete need answers will be approximately and not accurate. So, improve your question
Ahmad Abd-Elghany 9-Aug-13 3:55am    
i tried to put the grid in the user control and when i drag it to my page and want to use
<columns><columns>to make my columns and bind it manually nothing happened
i want to know every thing
TryAndSucceed 9-Aug-13 19:04pm    
I am confused about your question. Can you explain what you really want?
Ahmad Abd-Elghany 9-Aug-13 22:28pm    
i updated it :)

1 solution

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#[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900