Monday, August 16, 2010

Does anybody know how to include controls in the DataGrid..?

The process of adding control to datagrid in different in Desktop Application and web application. The following is how you add a control to datagrid in a DeskTop Application :-





Let see how to add combo box:


1. Make a new class [say combostyle] which inherits the dataColumnStyle Class


2. define an instance of combobox in the class i.e dim combo as new combobox


3. now override the edit, paint, new etc. procedures to display and modify the combo box [as per your requirements].


4. once you have made your combostyle class, add an instance of the class to the dataTableStyle.GridColumnStyle.





I learned it after going through lots of article on msdn, codeproject etc. I don't remember the specific links. You can search the above sites. They will give you an idea how to go about it. Since each person's requirement is different, you most probabily will have to modify the codes given in these articles.Does anybody know how to include controls in the DataGrid..?
hi





check out this example. I have included dropdown list control in datagrid using %26lt;asp:templatecolumn%26gt;.





%26lt;asp:TemplateColumn HeaderText=';Status';%26gt;


%26lt;HeaderStyle Width=';0px';%26gt;%26lt;/HeaderStyle%26gt;


%26lt;ItemStyle HorizontalAlign=';Left'; Width=';70px'; VerticalAlign=';Middle';%26gt;%26lt;/ItemStyle%26gt;


%26lt;ItemTemplate%26gt;


%26lt;asp:DropDownList ID=';ddlBestStatus'; Runat=';server'; CssClass=';textbox1'; OnSelectedIndexChanged=';ddlBestStatus_Se鈥?br>

AutoPostBack=';True';%26gt;%26lt;/asp:DropDownList鈥?br>

%26lt;/ItemTemplate%26gt;


%26lt;/asp:TemplateColumn%26gt;





--------


u can also do the same using property builder.

No comments:

Post a Comment