Hello All,
I am having Trouble with a Gridview control In my asp.net/C# application. It contains Some boundFields and one checkbox field. My gridview allows Editing. It succesfully enters edit mode and when i hit update the Datasource updates but the control will not return to readonly mode. I have gone far enough to figure out the problem is caused by the Checkbox field.The checkbox works and passes the correct true/false value to the datasource but will not bind after update When I Make it readonly and remove that value from my Stored Procedure the Gridview control works normal. Please help.
15 15771
I don't understand what you're doing.
You have a GridView that has a checkbox field.
You Edit a record in the Grid view and update the database.
Now what what are you doing??
What is the problem?
Usually when you have a Gridview than can be edited you click the edit button and all the editable fields become Textboxes and the Checkbox is Enabled. I change the values and click update but the gridview stays in Edit mode instead of canging back to Readonly and displaying the new results. If i hit cancel the Grid changes modes and i see the new values. Usually the gridview returns to readonly after update's. I figured out this problem is caused by the Checkbox field . Once i remove this field from my gridview it works (changes modes back and forth) Is there an alternative to the Checkbox that will return true/false?
Once you're finished updating have you tried setting the GridView's EditIndex property to -1?
Like (vb): -
Private Sub myGridView_RowUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewUpdatedEventArgs) Handles myGridView.RowUpdated
-
myGridView.DataSource = _source
-
myGridView.EditIndex = -1
-
myGridView.DataBind()
-
End Sub
(C#) -
Private void myGridView_RowUpdated(Object sender, System.Web.UI.WebControls.GridViewUpdatedEventArgs e)
-
{
-
myGridView.DataSource = _source;
-
myGridView.EditIndex = -1;
-
myGridView.DataBind();
-
}
Yes I have tried that. Sorry I should have posted. That does not resolve the problem.
Thanks
Please post the ASP code for your GridView and post your C# code for the GridView's Update method.
- <asp:GridView ID="gvModules" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSourceModulesManage"
-
EmptyDataText="No Modules" SkinID="GridViewSmall" Visible="False" DataKeyNames="ModuleId" onrowupdated="gvModules_RowUpdated">
-
<Columns>
-
<asp:CommandField ShowDeleteButton="True" ShowSelectButton="True" ButtonType="Button" />
-
<asp:BoundField DataField="Number" HeaderText="Number" SortExpression="Number" />
-
<asp:BoundField DataField="MODName" HeaderText="MODName" ReadOnly="True" SortExpression="MODName" />
-
<asp:BoundField DataField="ModuleSubType" HeaderText="ModuleSubType" ReadOnly="True"
-
SortExpression="ModuleSubType" />
-
<asp:BoundField DataField="ModelName" HeaderText="ModelName" ReadOnly="True" SortExpression="ModelName" />
-
<asp:BoundField DataField="TargetParticipantUseDays" HeaderText="TargetParticipantUseDays"
-
SortExpression="TargetParticipantUseDays" />
-
<asp:CheckBoxField DataField="NeedsParticipantCompliance" HeaderText="NeedsParticipantCompliance"
-
SortExpression="NeedsParticipantCompliance" />
-
<asp:BoundField DataField="AcceptableWeekDays" HeaderText="AcceptableWeekDays"
-
SortExpression="AcceptableWeekDays" />
-
<asp:BoundField DataField="AcceptableWeekendDays" HeaderText="AcceptableWeekendDays"
-
SortExpression="AcceptableWeekendDays" />
-
<asp:BoundField DataField="AcceptableHours" HeaderText="AcceptableHours"
-
SortExpression="AcceptableHours" />
-
</Columns>
-
</asp:GridView>
I am using SqlDataSource and do not have C# code for update. The onrowupdated code is exactly like to code you posted earlier.
...then where are you setting the GridView's EditIndex = -1?
I set EditIndex to -1 in the Properties window in design mode.
Try implementing a method that handles the GridView's RowUpdated event.
In that method set the EditIndex to -1.
As i mentioned earlier i am using the OnRowUpdated Code like you posted earlier in the OnRowUpdated Event Handler and settint the EditIndex to -1 and Calling the Gridview.DataBind() Method.
Please post that code then :)
- protected void gvModules_RowUpdated(object sender, GridViewUpdatedEventArgs e)
-
{
-
gvModules.DataSourceID = "SqlDataSourceModulesManage";
-
gvModules.EditIndex = -1;
-
gvModules.DataBind();
-
-
}
Hi stefbek97,
Something in your question is not adding up.
I took your GridView, created an ObjectDataSource that matched the Fields that the GridView was displaying and bound the GridView to it so that I can see what you're "seeing".
What I discovered is that you only have a Select and a Delete Button.
There is no control in the GridView that you posted used for "Updating".
So how can you be having a problem with the GridView Mode change after an "Update" occurs.
Your question doesn't make any sense.
Hello Frinavale,
I understand your concern. I tried to delete and create the gridview over and over to see if there are any errors I made. I changed it from Template fields to boundFields. From CommandField to Buttons "Edit","Update","Delete" with matching Command Name's. My fault i submitted the code and did not verify it. If you and the ShowEditButton="true" please let me know if you can see what i am seeing.
Please post your current version of the ASP code for your GridView and I will try to understand your problem again based on your most current version.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Mike Kelly |
last post by:
I've chosen to implement the "optimistic concurrency" model in my
application. To assist in that, I've added a ROWVERSION (TIMESTAMP) column to
my main tables. I read the value of the column in my...
|
by: Raja |
last post by:
Hi Everybody
Just playing with ObjectDataSource and noticed the following.
I have a Gridview which binds to a ObjectDataSource. ObjectDataSource
gets data from a typed dataset created with VWD. In...
|
by: sach |
last post by:
Hi,
I am trying to update my gridview using updatestatement..(vs.net 2005)
the data gets displayed and after changing it, when i clicked update,nothing
happens..it just stays the same..and no...
|
by: sck10 |
last post by:
Hello,
I have a web page that has a GridView and a FormView, each in its own
panel. The GridView shows a list of records in a database. When a row in
the GridView is selected the FormView...
|
by: landesjoe |
last post by:
Hi,
here's my problem in short: Text boxes in gridview don't seem to hold
their value if the column's .Visible property is changed back and
forth.
I've got a form with a gridview populated from...
|
by: Evan M. |
last post by:
Here's my GridView and my SqlDataSource
<asp:GridView ID="ContactHistoryGrid" runat="server"
AutoGenerateColumns="False" DataSourceID="ContactHistoryDS"
DataKeyNames="JobHistoryID"...
|
by: savajx1 |
last post by:
I need to dynamically create a set of bound fields contained in a
GridView control. I also have a single static CommandField that I can
declare in the Columns <tagof the GridView control. I have...
|
by: =?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?= |
last post by:
I setup a simple gridview as a utility just to do some updates, nothing fancy
just wanted easy UI to make updates. When I select ‘Edit’, I get the fields
I want to edit. I edit them and click...
|
by: pvong |
last post by:
VB.NET
How do you change a gridview from Update mode to normal mode? I'm usually
dealing for Formviews and there is a ChangeMode option but I don't see one
for Gridviews.
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |