How to add the delete/edit buttons in GridView control ?

i have a GridView control that is bound dynamically to an AccessDataSource.

the GridView control has the attribute 'AutoGenerateColumns' to be true.

when i add a 'delete field' to the grid control (by code or by the edit columns feature), it gets added in the beginning of each row. however, i want it to be at the end of each row .

how i can do it ?

thanks

0
dihmy
5/19/2007 9:16:27 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

7 Replies
1075 Views

Similar Articles

[PageSpeed] 12
Get it on Google Play
Get it on Apple App Store

 <asp:GridView ID="GridView1" runat="server" DataSourceID="SqlDataSource1">
                <Columns>
                    <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
                </Columns>
        </asp:GridView>
           


Girijesh
http://www.girijesh.in/
0
Girijesh
5/19/2007 10:10:45 PM

 

that still makes the delete/edit button appear in the left (in the beginning).

how to make it appear on the right (end of each row) .

please this is very important .

 

0
dihmy
5/20/2007 8:58:40 AM

Click on the smart tag of the gridview( small arrow on the upper right corner) and select Edit Columns. In the dialog box and your re-arrange the columns from the Selected fields listbox.

Thanks


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
5/20/2007 10:18:41 AM

Use Edit Columns option. It is used for arrange the fields and buttons.

0
pbarunkumar
5/20/2007 10:20:58 AM
thats okay when i bind the data using the wizard. 
my case is to bind the data dynamically. which means there is no columns before compilation. when i add the delete field using the smart tag it add it to the beginning of the row.
i hope you get my point.
thanks
0
dihmy
5/20/2007 3:34:46 PM
Hi, dihmy: 

Girijesh has presented the answer to your problem.

But there is another point I want to stress that you should put the code
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
at the end of the column, like

<Columns>
<asp:HyperLinkField FooterText="Test" DataNavigateUrlFields="name" DataTextField="name" Target="_blank" HeaderText="Open Link"  />
                <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" >
                </asp:BoundField>
                <asp:BoundField DataField="number" HeaderText="number" SortExpression="number" >
                </asp:BoundField>
                <asp:BoundField DataField="age" HeaderText="age" SortExpression="age" />       
                <asp:CheckBoxField DataField="isMarried" HeaderText="isMarried" SortExpression="isMarried" />
                <asp:BoundField DataField="birthday" HeaderText="birthday" SortExpression="birthday" />
                <asp:CommandField ShowEditButton="true" />
</Columns>

 

It works well.

 


Sincerely,
Techie Zhang
Microsoft Online Community Support
0
Techie
5/21/2007 4:20:13 AM

dihmy:
the GridView control has the attribute 'AutoGenerateColumns' to be true.
 

Techie Zhang - MSFT:
Hi, dihmy:

Girijesh has presented the answer to your problem.

But there is another point I want to stress that you should put the code
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
at the end of the column, like

<Columns>
<asp:HyperLinkField FooterText="Test" DataNavigateUrlFields="name" DataTextField="name" Target="_blank" HeaderText="Open Link"  />
                <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" >
                </asp:BoundField>
                <asp:BoundField DataField="number" HeaderText="number" SortExpression="number" >
                </asp:BoundField>
                <asp:BoundField DataField="age" HeaderText="age" SortExpression="age" />       
                <asp:CheckBoxField DataField="isMarried" HeaderText="isMarried" SortExpression="isMarried" />
                <asp:BoundField DataField="birthday" HeaderText="birthday" SortExpression="birthday" />
                <asp:CommandField ShowEditButton="true" />
</Columns>

It works well.

-MSFT next to your name? Huh! When the "AutoGenerateColumns" is set to true, you dont find BoundFields. All you will see in the SelectedColumn list is the EditButton and it appears in the first column. The user needs to add the BoundFields explicitly and re-order them.

Thanks


Mark post(s) as "Answer" that helped you

Electronic Screw
Website||Blog||Dub@i.net
0
e_screw
5/21/2007 5:44:15 AM
Reply:

Similar Artilces:

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

using javascript getting value from textbox when edit button is clicked and both controls are present in gridview control
Hi All using javascript I want to get value  from textbox when edit button is clicked and both controls that is texbox and button are present in gridview control .Alok Hi aloksinha83, Please see this post: http://forums.asp.net/t/1069245.aspx Thanks,Qin Dian TangMicrosoft Online Community SupportPlease remember to mark the replies as answers if they help and unmark them if they provide no help....

Programatically addding controls to GRidView Control
Hi , I am trying to add a template field (image button and calender control) both in one data cell of a Grid View. Initially my image button is visible and calender is invisible. And I want to make calender visible and image invisible once I click on image . But When I click on image it does not show image and calender both. When I checked in debug mode none of the controls are getting added to the desired cell. I am not sure why the controls are not getting added. I have kept the DataControlRowState in Edit mode. Any help would be highly appreciated. Regards, VB...

In a gridview, can I programatically control display of edit/delete buttons for selected row?
Hi there, I'm sure this is something fairly straight forward but I'm only just getting used to working with gridviews so please help me, I am displaying the select button on my gridview, and on the SelectedIndexChanged event I would like to add (or make visible) the edit and delete buttons just for the selected row - can I do this?  All help appreciated, JoH are you using template field with button / link button for edit or delete button  ?Thanx, [KaushaL] || BloG || Profile || Microsoft MVP"I would love to change the world, but they won’t give me ...

this.Controls.Add does not add control to child collection (this.Controls.Count == 0)
Ok, as silly as it may sound, I have a situation where I am creating a CompositeControl in ASP.NET 2.0, C#. I have the following code in the CreateChildControls() method that build the control's child control collection: 1    for (int i = 0; i < _menus.Count; i++)2    this.Controls.Add(_menus[i]);3    4    foreach (FloatingMenu menu in _menus)5    {6    Label lbl = new Label();7    lbl.ID = string.Concat("GroupQ", menu.ID);8    lbl.CssClass = "menuIt...

How to delete controls in GridView when the delete button in a row is clicked
Hi,   I am having issues with my gridview.....i added 2 dropdown and 2 compare validators....whenever i delete a row though......the dropdown and compare validators are becoming null........thus when i click a button, it is still validating.............anyway to delete this when i click the delete button or even handle?   Please help.  ...

how to add multiple buttons to the footer of the gridview control for each of gridviews field.
I have a gridview and i want a button at the "Footer" on each field of the gridview . can somebody reply to this soon. you need to program in the itemcreated event of the gridview If(e.Row.RowType = DataControlRowType.Footer){Button btn = new Button();btn.Text = ""; ///...Set other properties also e.Row.Controls.Add(btn);}Vikram www.vikramlakhotia.comPlease mark the answer if it helped you thanks for your reply vikram however there is not "Itemcreated" event associated with gridview Hi vijay_ande2007 , Try to use RowCreated event instead. The event...

Add .Net Control to Web Custom Control
 I want to add .NET Control (like: TextBox, Button...) to Web Custom Control.How i can do it? Alphavn That's called a composite control -- "Mark As Answer" if my reply helped you -- Hello Guys What gunteman said, that is one approach and in most cases the right one.But its also possible to add child controls to a Control thats inherit from WebControl itself. Be sure to implement INamingContainer to that inherited Control too, thats the important point of that approach.--Microsoft MVP - Visual Developer ASP / ASP.NET- http://www.aspnetzone.de/blogs/peterbuch...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one colum.now my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the data.now my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

Edit data with GridView Control ? or another control ? help
I use GrivView in ASP.Net 2.0 to show data from DataTable. And i want to edit some fields in some rows. How can I do it? If i touch EDIT button - all columns, which have ReadOnly=false, switch into EDIT mode. But I want, that in first raw I can edit 2,3 column and in second row only 3 column. How can I do it ? ...

Controls.Add in Composite Control that inherits another control
Hi! I created a composite control that inherits from the WebControls.Button. I added the following in the Load event:         Dim mHidden As New WebControls.HiddenField        Me.Controls.Add(mHidden) but the control is not created. Why?Dimitris PapadimitriouSoftware Development Professional Hi,Child controls on Button do not make much sense (how would you expect them to be rendered, doesn't button allow only text into value attribute?). Button allows child controls to be added, but they won't be rendered b...

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say it...by the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,MCAD.net,MC...

Handling control events while in edit mode for a gridview control
I have a dropdownlist and checkbox in a single column of a gridview. While the row is in edit mode, I want to set the visibility of the checkbox based on the value selected in the dropdown list. I can do this easily enough  when the row is first put into edit mode, but how do I access the dropdown list's change event when the row is already sitting there in edit mode? Thanks for any help you can provide.   Penny Penny, Just create a SelectedIndexChanged event like below. Create a row object for the currently edited row, find the checkbox you want to control, then set the Visib...

OnBubbleEvent with Button (child control) in GridView (parent control)
I have a button (created at runtime) inside the gridview.  I'm having a hard time telling the grid view that row 1 (the row which was selected when the button is clicked) is selected. Here's my code so far:  protected void ContentsGrid_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { counter++; //Display Imagebutton for View in column 1 ImageButton imgView = new ImageButton(); imgView.ID = "imgView" + c...

Web resources about - How to add the delete/edit buttons in GridView control ? - asp.net.presentation-controls

Resources last updated: 11/29/2015 7:41:50 PM