Please do help me with the following problem.
In my C#
Application Program, I have a DataGridView control. There are several
rows and columns without data in it. And I need some type of a control
(say, a lable or a button or a textbox - any control of my choice) to
be able to dragged and dropped on this DataGridView so that it fits
into the cell when I drop the control.
This dragged control in
reality is do be drawn (or created) at runtime, but for the time being
if I can get a predefined control to get the desired functionality,
that would suffice.
Please do help with this. I checked this
forum as well as a few others but couldn't find an answer. Also, please
do explain how I get the drag-drop functionality to any control as
well.
Thanks in advance!
Loading
paiha paigaPosted Oct 30, 2008, 2:41 AM
Hi!
First of all you would have to take the templatefield of the columns of gridview instead of boundcolumn like
i mean use this one below.
<
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"><
Columns><
asp:TemplateField><
ItemTemplate> ItemTemplate> asp:TemplateField> Columns> asp:GridView>Not use this below code other wise you cannot drag and drop the control so use the Template Field instead of Bound Field.
<
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"><
Columns><
asp:BoundField >asp:BoundField> Columns> asp:GridView>After calling the Template field then Go to the Design mode of the DataGridView and Make the Right click on the Gridview and choose the EditTemplate Option and select the desire columns and edit that one in Design Mode and after that you can drag and drop your desire control i.e button, text fiel or Label etc.
If you want to code in inline.you can write below code and i can say after accomplishing work in design mode your code in inline will be as below with dragging label and button controls.
<
asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"><
Columns><
asp:TemplateField><
ItemTemplate><
asp:Label ID="Label1" runat="server" Text="Label">asp:Label> ItemTemplate> asp:TemplateField><
asp:TemplateField><
ItemTemplate><
asp:Button ID="Button1" runat="server" Text="Button" /> ItemTemplate> asp:TemplateField><
asp:TemplateField><
ItemTemplate> ItemTemplate> asp:TemplateField> Columns> asp:GridView>You can drag and drop every thing in inline code of the project as like as design mode.
Enjoy with this.
Thank you..