How could I edit at the same time the GridView and DetailsView - c#

I´m working with a detailsView ans a GridView, within the DetailsView I have the ModeChanging event that allows the fields to be editable, I´d like that when I click on the modify button also allows edit the GridView fields without of the AutoGenerateEditbutton attribute, so that with this I could edit at the same time the DetailsView and GridView.
Is this possible?
thanks.

Set the EditIndex of your GridView to the row you want to edit on the modechange event of the detailsview. And remember to DataBind().

Related

How to get data from database to CheckboxList control inside a form view control?

I am working on asp.net user control. I have used a gridview and a formview control.
on selecting a row in gridview it will hide the panel containing the grid and will display the panel containing the form view which is using the Grid's selected value as its key value and form loads in edit mode. for some extra use i had to place a checkbox list control in my form view control. and used SQL datasource to fetch data from databese to chkbox list. and used the same data key as formview control. Now my form view control works properly but my Checkbox list is not working properly as it cant get the selected value from grid view.
Thanks in advance for help.
You should bind your CheckBoxList on the DataBound event of your FormView.
Since you would need the same data key, you could use the DataKey property of the FormView.
If any additional data fields are required, you always have the DataItem property.
Done in this order, your CheckBoxList should work as expected.
I used a session variable and it worked for me.
i used a session variable to store the selected value of grid in its selected index changed event and then used it as key value in checkbox list.

How does one turn a Gridview Row clickable which open a modalpopup in C#?

How does one turn a Gridview Row clickable which open a modalpopup in C#?
I have a gridview with several columns. Each row (the entire width of the row) needs to be clickable which onclick opens a modalpopupextender displaying a popup panal with detailed info on the row.
I have the modalpopupextender & panal working properly when an ImageButton is clicked. However I am removing the ImageButton and replacing its functionality with the row onClick.
I appreciate your time!
You should change the SelectionMode property to FullRowSelect.
You could use the SelectionChanged event to determine the current row selected.
GridView.SelectedRows[0].Index
will give you the index of the selected row. You will have to be sure MultiSelect is disabled as well.
So you have the index of the row selected, so now open whatever form needs opened depending on this index
Check this:
Edit Update GridView With Ajax ModalPopUpExtender Example
This Example explains How To Edit Update GridView Rows Records With Ajax ModalPopUpExtender In Asp.Net Using C# and VB.NET.

How to update a single column of a selected row in gridview using a button?

I have a Select button at the end of each row in gridview. I also have a separate button that I want to use to update one of the column of the selected row. This column contains a checkbox, I want to put a check in it when I click the button.
I do not want to use an Update button inside the gridview because I do not want the user to be able to change any other column.
Can anyone help? I have been researching this for a while now.
You've got a lot of option regarding your problem..
You could use Gridview's RowCreated or RowDataBound events or even on the buttons onclick event if that button is on the same row of the gridview(just get the sender etc//based on your logic).
here are some code snippet
If
e.Row.RowType = DataControlRowType.DataRow Then
e.Row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(sender,
"Select$" & e.Row.RowIndex.ToString))
End If

GridView Add TextBox TemplateField Into Footer CodeBehind

Suppose I have one template field
TemplateField FooterField = new TemplateField();
FooterField.ItemTemplate = //my code (basically setting it to display a button)
I then define what the FooterField should do during gridview editing mode like this:
FooterField.EditItemTemplate = //my code (entering editing mode when the button is clicked)
Now my question is: how can I insert this TemplateField into the gridview Footer?
You need to add your template field to GridView columns - each data control field essentially decides what is the contents for that column for header, footer and data rows. Grid-view being a table, you cannot have a field in footer without having column for it.
If your requirement is to have some UI (which is not columnar in nature) in the footer then you can inherit from GridView and override CreateRow method to substitute your own UI for a footer row. However, instead of going this route, I would rather design a user control that would probably show edit UI by capturing grid-view edit event - for example, you may use Grid-View and DetailsView together.

ASP.NET GridView focus selected row

I am fairly new to ASP.NET. I have a GridView control which has many rows. Based on selection of each row I need to enable/disable few list and text controls on the collapsible panel in a ASCX.
The issue I am facing is whenever I select any row the GridView sets the focus on the first row all the time due to postback.
How do I set the focus on the selected row?
Can I use GetPostBackClientHyperlink in the RowDataBound somehow to register a client-side script?
Reply with some code is much appreciated.
Add a handler to the SelectedIndexChanged event of your GridView and insert the following code into this handler:
GridView1.SelectedRow.Focus(); // where GridView1 is the name of your GridView
You can also use jQuery. I added a <div> with an ID that is only shown when a row is using the edit template.
$('#hiddenDIV').focus();

Categories