Is there a way to edit cells in the DataGrid XAML control for UWP with only one click or when they get focus? - datagrid

I know this question has already been asked for WPF DataGrid but the solutions don't apply to DataGrid from Windows Community Toolkit used in UWP.

You could use SelectionChanged and BeginEdit event to do this like following.
XAML code:
<controls:DataGrid x:Name="dataGrid1"
…
SelectionChanged="dataGrid1_SelectionChanged">
Code behind:
private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
dataGrid1.BeginEdit();
}

Related

asp.net dynamic user control button click issue

I made researching about this subject I could not find proper answer.
In my default.aspx page, I have a treeview. Codes are in default.aspx like below:
protected void Page_Load(object sender, EventArgs e)
{
}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
Control ucont;
if (TreeView1.SelectedNode.Value == "Yeni Dönem")
{
ucont = LoadControl("usercontrols/yenidonem.ascx");
PlaceHolder1.Controls.Add(ucont);
}
else
{
ucont = LoadControl("usercontrols/tabloktar.ascx");
PlaceHolder1.Controls.Add(ucont);
}
}
I load user controls dnynmicaly. User controls are have button control. I can not fire user control's button click when I load it dynamcally. How can I solve this ?
Thanks.
First of all, I would not recommend adding control dynamically later than in Page_Load event. Other things to remember is that You should add it on each page load and assign unique ID value the control that does not change between postbacks.
In this case, the easiest way would be to always add both controls to the page and show appropriate one using Visibility property.
If that's not suitable for You, try to move the code from TreeView1_SelectedNodeChanged to the Page_Load event and load appropriate control on each postback until it should be changed to another one.
I haven't tested this, so if You have any issues when using thise answer, let me know in the comments and I'll try to help.

How to Show Telerik Report in ReportViewer in Asp.net?

I want to show Telerik Report in Telerik ReportViewer in Asp.net page. I have create a Class Library Project and Telerik Report in it, configure correctly, it show data in preview. Also created an asp.net website and AddReference of class Library Project in it.
Now, how do I show Report in Telerik ReportViewer Control?
You can use the following code:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var instanceReportSource = new Telerik.Reporting.InstanceReportSource();
instanceReportSource.ReportDocument = new YourClassLibrary.YourReport();
this.ReportViewer1.ReportSource = instanceReportSource;
}
}
You can also set the ReportSource declaratively from the ReportViewer properties.

How to implement paging in gridview in a modular popup?

I am using a modular popup to show gridview in a popup. Now I want to implement paging of this gridview. When I click on the page number the popup disappears. How do I avoid it? I want it to disappear only when clicking close button.
I assume that you're using the ModalPopupExtender from the AjaxControlToolkit.
If you're posting back you always need to call ModalPopupExtender1.Show() in codebehind when you want it to stay visible.
You could simplify it by using Page_PreRender if you have many events and you don't want to remember this always:
protected void Page_PreRender(object sender, System.EventArgs e)
{
// change "this" to somewhat appropriate for example your GridView
// "this" makes sense for example in a UserControl
if (this.Visible) {
this.ModalPopupExtender1.Show();
}
}

Adding or attaching an OnItemCommand Event handler to ASP.NET CheckBox

I wonder if it is possible to add or attach or extend the asp.net checkbox in a way to add OnCommand , CommandName, CommandArgument functionality.
In brief I want to add to a asp. net CheckBox the OnCommand functionality like Button or LinkButton has.
I want to place a check box in a Repeater ItemTemplate and want to handle on checkbox clicks in OnItemCommand handler.
I solved my problem using a simple trick. I created a web user control using a checkbox and invisible link button.
<asp:CheckBox ID="cbSelector" runat="server" AutoPostBack="true" />
<asp:LinkButton ID="btnHiddenCheckBox" runat="server" Visible="false" CommandName="Select"></asp:LinkButton>
in the code behind i added some event handlers ...
protected void Page_Load(object sender, EventArgs e)
{
cbSelector.CheckedChanged += new EventHandler(cbSelector_CheckedChanged);
}
void cbSelector_CheckedChanged(object sender, EventArgs e)
{
btnHiddenCheckBox.CommandName = "Select";
btnHiddenCheckBox.CommandArgument = Convert.ToString(cbSelector.Checked);
((IPostBackEventHandler)btnHiddenCheckBox).RaisePostBackEvent(null);
}
and programmatically raised a Click event with parameters and it works.
Patrik I am going to suggest you something completely different, use JQuery and get this done via Ajax so to give the users way smoother experience.
there is a nice article with a step by step here: ASP.Net CheckBox and JQuery
everything is better than a CheckBox or a Button with AutoPostBack set to true nowadays in year 2011, 2012 soon ;-)
The same could be achieved using OnCheckChanged event.
You can find out what the RepeaterItem is to be able to access controls in the same RepeaterItem
ALternatively, see this SO question for a solution on how to use OnItemCommand for CheckBox:
Checkbox OnClick/ItemCommand in Repeater or DataList

XtraGrid data source update while trying to edit

I have an XtraGrid with the datasource set to a BindingList. Some of the fields in the grid are editable. The problem is that the list gets a lot of updates for some other fields (not the ones I can edit), which causes the binding to refresh. If I was in a cell part way through editing a field, this is discarded and the editor closes.
Is there a way I can make the cell with the editor open not be refreshed? Or even make that whole row not refresh if I have to?
On the grid view you can call BeginDataUpdate() to "prevent visual and internal data updates"
until EndDataUpdate() is called.
So you could do something like this (the events you attach to may be not be the best, but you get the idea):
private void gridView1_CellValueChanging(object sender, CellValueChangedEventArgs e)
{
gridView1.BeginDataUpdate();
}
private void gridView1_CellValueChanged(object sender, CellValueChangedEventArgs e)
{
gridView1.EndDataUpdate();
}

Resources