codefinger
asked on
Two clicks required to edit values in webform datagrid?
In a datagridview on a webform I have let it autogenerate an Edit button for each row, then I pop up a separate window for editing the row when the RowEditing event begins (user clicks on the Edit button). The datagridview itself is not editable.
However, I did NOT let it auto-generate a SELECT button, assuming that clicking EDIT on a row would automatically select it...however, that does not seem to be the case. No matter which Edit button is clicked on the web form, the values collected and sent to the new window come from the first row, NOT the row where the edit button was clicked.
Is an additional SELECT button required to select a row for editing? IOW, does the user actually have to click two buttons to begin the edit process?
What am I missing?
Thanks...
However, I did NOT let it auto-generate a SELECT button, assuming that clicking EDIT on a row would automatically select it...however, that does not seem to be the case. No matter which Edit button is clicked on the web form, the values collected and sent to the new window come from the first row, NOT the row where the edit button was clicked.
Is an additional SELECT button required to select a row for editing? IOW, does the user actually have to click two buttons to begin the edit process?
What am I missing?
Thanks...
Private Sub GridViewRegistrants_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridViewRegistrants.RowEditing
Dim ckbx As New CheckBox
Dim d_obj As New MyChartRegistration.BDL.DOBJ.DataObjects.PatientRegistration
d_obj.RecordID = CInt(GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_RECORDID).Text)
d_obj.FirstName = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_FIRSTNAME).Text
d_obj.LastName = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_LASTNAME).Text
d_obj.Address1 = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_ADDRESS1).Text
d_obj.Address2 = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_ADDRESS2).Text
d_obj.City = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_CITY).Text
d_obj.State = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_STATE).Text
d_obj.Zip = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_ZIP).Text
d_obj.ClinicNo = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_CLINICNO).Text
d_obj.DOB = CDate(GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_DOB).Text)
d_obj.Email = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_EMAIL).Text
d_obj.EpicActCode = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_EPIC_ACT_CODE).Text
d_obj.Gender = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_GENDER).Text
d_obj.Phone_Number = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_PHONE_NUMBER).Text
d_obj.SSN = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_SSN).Text
d_obj.Status = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_STATUS).Text
d_obj.Status_Updated_By = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_STATUS_UPDATED_BY).Text
d_obj.Status_Updated_On = CDate(GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_STATUS_UPDATED_ON).Text)
d_obj.Notes = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_NOTES).Text
' d_obj.Denial_Email_Sent = CBool(GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_DENIAL_EMAIL_SENT).)
Dim RowCheckBox As CheckBox = GridViewRegistrants.SelectedRow.Cells(Me.ColumnsByNumber_DENIAL_EMAIL_SENT).Controls(0)
If RowCheckBox.Checked Then
d_obj.Denial_Email_Sent = True
Else
d_obj.Denial_Email_Sent = False
End If
Session("CurrentRecordID") = d_obj.RecordID
Session("PatientDetails") = d_obj
Response.Redirect("UserDetails.aspx")
End Sub
ASKER
Those are some great tips, but I don't see my problem mentioned.
It is there:
Problem:
In a Grid link button (for example, clicking on Filename link button), a single click is not working sometimes. Instead double clicking is working.
Solution:
The events should be bound to the link button while data bound itself using onItemDataBound event.
In client side:
<asp:DataGrid ID="grdResources" runat="server" AutoGenerateColumns="False "
Width="100%" DataKeyField="ResID" OnItemDataBound="grdResour ces_ItemDa taBound">
Toggle HighlightingOpen in New WindowSelect All
In server side:
protected void grdResources_ItemDataBound (object sender, System.Web.UI.WebControls. DataGridIt emEventArg s e)
{
Private const URL = "some file name";
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingIt em)
{
lnkSelect.Attributes.Add(" onclick", "javascript:window.open('" + URL + "'); return true;");
}
}
Problem:
In a Grid link button (for example, clicking on Filename link button), a single click is not working sometimes. Instead double clicking is working.
Solution:
The events should be bound to the link button while data bound itself using onItemDataBound event.
In client side:
<asp:DataGrid ID="grdResources" runat="server" AutoGenerateColumns="False
Width="100%" DataKeyField="ResID" OnItemDataBound="grdResour
Toggle HighlightingOpen in New WindowSelect All
In server side:
protected void grdResources_ItemDataBound
{
Private const URL = "some file name";
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingIt
{
lnkSelect.Attributes.Add("
}
}
ASKER
I'm sorry, I still don't see the connection.
In my case, a click on an edit button "works" because the event IS activated, its just that the code to collect the values of the row that was clicked on picks up the first row, regardless of which row the edit button was clicked on.
I only asked about two clicks because at this point, it looks like I have to also generate a SELECT button, so the user will have to first click the SELECT button, then the EDIT button on the same row.
Hoping to find a better solution so the user only has to click one EDIT button on one row.
(Also, FWIW, I have found the databound event is very unreliable when working with a webform. Nothing is actually bound after the grid populates.)
In my case, a click on an edit button "works" because the event IS activated, its just that the code to collect the values of the row that was clicked on picks up the first row, regardless of which row the edit button was clicked on.
I only asked about two clicks because at this point, it looks like I have to also generate a SELECT button, so the user will have to first click the SELECT button, then the EDIT button on the same row.
Hoping to find a better solution so the user only has to click one EDIT button on one row.
(Also, FWIW, I have found the databound event is very unreliable when working with a webform. Nothing is actually bound after the grid populates.)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your problem is mentioned with solution please check it out.