Gridview: Click edit button causes my Gridview to disappear.

When I use the following code, and click the "Edit" button for one of my rows, the entire Gridview dissapears on postback...

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

If Page.IsPostBack = False Then

MainCats.AutoGenerateColumns = True

MainCats.AutoGenerateEditButton = True

MainCats.DataSource = MainCategory.FetchByParameter(MainCategory.Columns.Status, Comparison.Like, "ACTV")

MainCats.DataBind()

End If

End Sub

 

Protected Sub MainCats_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles MainCats.RowEditing

MainCats.EditIndex = e.NewEditIndex

DataBind()

End Sub
 
Best regards,

Jeremy Hodges | Windows Server 2003 MCP
Managed Microsoft hosting: www.orcsweb.com
0
madkidd
3/19/2007 10:06:47 PM
asp.net.presentation-controls 72751 articles. 3 followers. Follow

5 Replies
2381 Views

Similar Articles

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

why are you trying to bind inside the RowEditing method? I dont' think you need to do that unless you want to do soemthign with it

Just for the kick..what's that DataBind() method? Shouldn't it be MainCats.DataBind()?

Liming Xu
Jumptree ASP.NET 2.0 Project Management - With Source Code, Free to Non Profit Org and Effectively Manage Projects/Tasks/Milestones
0
Liming
3/19/2007 10:53:35 PM

When I try MainCats.DataBind() I get the same thing.

When I do it without the databind and click "Edit" nothing happens the first time, the second time the changes, shows the textbox but is empty. You then get some strange behavior where the click seems to be one behind. I did some searching on that issue and that is where I got to do the DataBind()


Best regards,

Jeremy Hodges | Windows Server 2003 MCP
Managed Microsoft hosting: www.orcsweb.com
0
madkidd
3/19/2007 11:34:56 PM

Dear, friend:

Would you plz dump some code about your aspx page?


Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support

If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
0
Rex
3/20/2007 2:31:28 AM

The code behind page was in the first post. My ASPX page just has this:

 <asp:GridView ID="MainCats" runat="server"></asp:GridView><br /><br />


Best regards,

Jeremy Hodges | Windows Server 2003 MCP
Managed Microsoft hosting: www.orcsweb.com
0
madkidd
3/20/2007 3:07:56 AM

Dear, friend:

I test it and got into the similar scenario like yours. Then i got to know that if you assign the dataSource of the GridView in the Page_Load event, it will be losted after the post back. So you have to reassign the DataSource of the GridView again in the Editing event:

 

I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance


Best Regards,
__________________________________________________
Sincerely,
Rex Lin
Microsoft Online Community Support

If there is any question or the issue is not resolved, please feel free to mark the thread as not resolved
0
Rex
3/20/2007 3:37:55 AM
Reply:

Similar Artilces:

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....

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 ...

GridView and Javascript
Hey All, I need help from  you. I have a GridView. In the  Edit Item template of the first Column I have a textbox, an user control and hidden field. When I click on the user control it  opens a pop up from which I can choose the required value. The text value is populated in the textbox and Id in the hidden field. Here's the code for edit template.         <EditItemTemplate>                        <table cellpaddin...

Enable Radiobutton in Gridview that has Alternate rows when edit button is clicked, using GridView.RowCreated
OK I have a gridview that has alternate rows enabled to make it look pretty :) I also have Radiobuttons in an ItemTemplate that are disabled (from editing) on the load of the gridview.  What I want to do is when I click Edit I want the radiobuttons enabled.  Well I got that part down accept every other will not enable the radio buttons.  I know I have to check the status of the row to see if it an alternate row but how would I then enable the controls on that row for edit.  Here is my code I have been playing with.   any suggestion would be great...  1 &...

editable gridview when user click external edit button
Hi Friend, I have gridview with columns id, fname, lname and email. I have bound the gridview from the table. Now my requirement is: I need to have editable gridview with edit button external to gridview. I can do it, if the edit button is internal to gridview. But I want to achieve editable gridview when user click external edit button. Is it possible or any other control that have this future?  Thanks, FarooqMark as answer if this post helpfull to you.Don't be afraid to be wrong; otherwise you'll never be right.  Do you want to make a certain row editable or t...

Clicking templated controls inside <frame>/aspx/UpdatePanel/Gridview cause .net ajax javascript runtime error
I have templated controls in UpdatePanel/Gridview. Clicking the controls in regular aspx will work fine - get postback and updatepanel render fine. If I put the aspx inside frameset <frame>. Clicking controls will cause javascript runtime error - Line: 5820, Sys.ArgumentOutOfRangeException: Value must be an integer. Parameter name: x Actual value was NaN. And updatepanel does not render correctly. Does anyone have same problem, know workaround? Is there anyway to change javascript and incorporate to Web.Extensions.dll?    Sample code: **** MainEntry.aspx - <framese...

after pressing delete button in gridview, the gridview disappear :/
well i have a gridview. when i press the delete button , it delete the row but on page postback there is no gridview ?! then i refresh again and it appear. :D   here is my selectcommand :if (string.IsNullOrEmpty(ImageName)) {DefaultPhotoParser df1 = new DefaultPhotoParser(); string foo = df1.GetDefaultphoto(nick);string DefImageName = System.IO.Path.GetFileNameWithoutExtension(foo); SqlDataSource1.SelectCommand = "select * from tb_comments where Picture_ID = @pic_id";SqlDataSource1.SelectParameters.Add("pic_id", DefImageName); } else {string AlternativeI...

button under gridview under gridview
I got gridview under gridview in which one button is there in child gridview how we write code behind button like how to call button event handler <asp:GridView ID="GridView1" runat="server"> <Columns> <asp:TemplateField HeaderText="Names"> <ItemTemplate>   <asp:GridView runat="server"> <Columns> <asp:TemplateField HeaderText="LastName"> <ItemTemplate> <asp:Button ID="name" Text="LastName" runat="server" /> </ItemTemplate> </asp...

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...

Direct editing of gridView or Ddatagrid controls without clicking on an EDIT link
I have an application where lots of data is presented to the user in a gridView control and the user needs the option to review and overwrite any values in the cells of the grid.  My users find it very annoying and time consuming to click on an edit link to turn a row of the gridView into edit mode.  Typically, they might jump around and edit a few values in several rows.  Is there any way to present the data in a gridView control, datagrid control or something that looks like a grid where the entire grid is already in edit mode?  Can you make a grid that cont...

GridView control enters edit mode only when I click Edit link twice
Hi all..I have a GridView control in an ASP.NET 2.0 page. I added a column that contains edit, update, cancel buttons. Because I did that, I had to handle RowEditing event or an exception was thrown.Well... this is the body of the RowEditing event:protected void gvParametros_RowEditing(object sender, GridViewEditEventArgs e){      gvParametros.EditIndex = e.NewEditIndex;}The fact is that when page is loaded and I click the edit link, page is refreshed but GridView doesn't enter edit mode. When I press edit link again, GridView enters edit mode.Any help to solve this behavior w...

How to update Gridview through a Button(button
Hi there,I was wondering, if any one can help me in updating a Gridview through a button outside the grid (a button in the Form)I managed to do the same with a Datagrid..and the code goes...protected void button1_click (...){     foreach(datagriditem grdItem in datagrid.Items)    {     /// My update query     }}I'd be happy if I get one, similar to Gridview..  Cheers,Vino.     protected void button1_click (...){     foreach(GridViewRow grdItem in gridview.Rows)&n...

how to place a selected row from a gridview into another gridview by clicking a button
hi, In my application  i have binded the data from data base table to a grid view. my database table attributes are prodid,prodname ,price and qty. my grid view columns includes qty,prodname,price.i placed checkbox into my gridview and i placed a textboxes in the last column for placing required  qty from the available qty.after clicking on a checkbox of a perticular row  that selected row should be placed into another grid view by clicking on a submit button. the second gridview columns are serial no,prodname,qty(user required qty ), total price. in the last row of grid...

Gridview control embedded in another gridview control
I am writing an ambulance crew scheduling application on the web and I need some help completing the last part.  I have an access database that has three tables: user table, shift table (describing the shifts available), and a schedule table (that stores shift by shift_id and user by user_id).  I have a gridview control that will display the available shifts but I cannot get the embedded gridview control that will display the user that is signed up for each shift to display because I cannot figure out how to use the OnRowDataBound method.  I need a simple VB example of how to...

Web resources about - Gridview: Click edit button causes my Gridview to disappear. - asp.net.presentation-controls

Resources last updated: 12/31/2015 7:51:04 AM