w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML Categories
ExecuteNonQuery with DeleteCommand?
Yes, if you're executing a DELETE statement, ExecuteNonQuery() on your MySqlCommand instance is what you want to use. It's also what you'd use if you're executing an INSERT or UPDATE statement or a stored procedure that doesn't return a resultset.

Categories : C#

delete procedure not call in sqldataadapter.Deletecommand in mvc3 razor
From the code above it seems that you don't change the contents of the tables Glhead and Gledg. Calling the Update method of the SqlDataAdapter when the rows of the mentioned tables are all in the state DataRowState.Unchanged result in no action on the database. When an application calls the Update method, the DbDataAdapter examines the RowState property, and executes the required INSERT, UPDATE, or DELETE statements iteratively for each row, based on the order of the indexes configured in the DataSet. You need to delete the row from the datatable and then call the Update method of the SqlDataAdapter

Categories : Asp Net Mvc

Update TableAdapter with DataSet - Update requires a valid DeleteCommand error
It means that you are using a DataAdapter to update a table which contains deleted DataRows (their RowState is Deleted). Then the DataAdapter uses the specified DeleteCommand to delete this row in the database. But you haven't provided it. So you need to provide it. MSDN example: public static SqlDataAdapter CreateCustomerAdapter( SqlConnection connection) { SqlDataAdapter adapter = new SqlDataAdapter(); // Create the SelectCommand. SqlCommand command = new SqlCommand("SELECT * FROM Customers " + "WHERE Country = @Country AND City = @City", connection); // Add the parameters for the SelectCommand. command.Parameters.Add("@Country", SqlDbType.NVarChar, 15); command.Parameters.Add("@City", SqlDbType.NVarChar, 15); adapter.SelectCommand = comm

Categories : C#

DataGrid edition 'EditItem' is not allowed for this view` when bound to a WPF DataGrid
I tried this and the problem is that you have initialized your Level2 collection as Hashset<>. IEditableCollectionView.EditItem() throws this error while trying to update item in Hashset<>. I initialized the collection as List<> and it was working fine. I am not sure why it is not able to update item in hashset, need to look deeper into it. But changing the Hashset<> to List<> will fix this error. Hope it helps Thanks

Categories : C#

Silverlight Datagrid scrolling, DataGrid fires RowLoading event
The RowLoading event is fired because rows are virtualized. With virtualization, rows are created (and loaded) only when they are visible on screen. So every time you scroll down or up a new row is created, loaded and the RowLoading event fired. To disable the virtualization you can try to set this property: VirtualizingStackPanel.VirtualizationMode="Standard" Be aware that this can slow down the performance of your grid if you have a lot of rows.

Categories : Database

Binding ComboBoxColumn to collection from DataGrid's ItemsSource in WPF DataGrid
MSDN: DataGridComboboxColumns says: To populate the drop-down list, first set the ItemsSource property for the ComboBox by using one of the following options: A static resource. For more information, see StaticResource Markup Extension. An x:Static code entity. For more information, see x:Static Markup Extension. An inline collection of ComboBoxItem types. So basically to just bind to data object`s collection property it`s better to use DataGridTemplateColumn: <DataGridTemplateColumn Header="Log"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <ComboBox ItemsSource="{Binding log}" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> This type of c

Categories : Wpf

Validating A WPF Datagrid Against Data From Another Datagrid
From Microsoft official WPF course materials: ValidationRules are only to be used as simple validations (For instance Required fields, numeric formats, etc). If you need advanced / complex Business Rules validation, you should either implement IDataErrorInfo or create your own validation mechanism (that's what I did and it works like a charm)

Categories : C#

Copy selected row from datagrid at the end of datagrid
For Datagridview Databound you have to commit additional record to datasource (table) So, you have to do "INSERT INTO mytable ( fields here ... ) VALUES ( values here ..)" then to refresh your datagridview .. dt2.datasource = mytable ADDED : For your code ... try change like this insert_cmd.Parameters.AddWithValue("@Name", .item("Name")) insert_cmd.Parameters.AddWithValue("@Age", .item("Age"))

Categories : Sql Server

Master-Detail: On row click in master (DataGrid), display details (DataGrid)
If you searched online, you would have found a number of answers. For example, please take a look at the following articles: WPF Master Details MVVM Application Implementing a simple Master-Detail scenario for WPF in MVVM MVVM - Master Detail

Categories : Wpf

Copying data from a datagrid view to a new form with a new datagrid view VB
"Error 1 Reference to a non-shared member requires an object reference." As this message says: You need a instance of form2 - object of type form2created with New sub, which you created inside of BTN_Next_Click. But local variable frm_PI_01 can be used only inside of that function. With name of class form2 you can used only Shared member or functions/subs MSDN Shared members in VB My opinion if you need transfer some information/variables from form to another then in your case(when you transfer data only once when creating form) use a parameters in form constructors. Add another parameter to you form3 constructor. For example reference of your datagridview(this is may be not good practice referenced controls to another form, better create some variable with needed data and reference th

Categories : Vb.Net

Binding datagrid in datagrid
You have problem with DataContext here. In RowDetailsTemplate you trying to binding to a property in main view model, but DataContext of RowDetailsTemplate is the row item. If you want to binding to property in your main view model you should use RelativeSource binding. Try this: <DataGrid ItemsSource="{Binding Path=Files}" SelectedItem="{Binding Path=DataContext.CurentFile, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=Window}}" AutoGenerateColumns="False" > ...

Categories : Wpf

How can embed datagrid in datagrid
I don't think it's possible. You can indeed manually replace a cell with the HTML of another grid (your "child" grid), but Dojo maintains its data in a store. Your store won't be "aware" of any changes you make in the DOM nodes of your grid, and inserting a DataGrid in a store isn't possible either since the DataGrid maps its columns to properties of the data objects.

Categories : Database

How to add a new row in sql from datagrid and update sql row from same datagrid?
This article on codeproject does a nice (thorough) job of demonstrating what you are asking. It also comes with some demo code. http://www.codeproject.com/Articles/37430/Datagrid-Editing-Updating-Cancel-Selecting-Rows

Categories : SQL

DataGrid Does not seem to allow editing
Ok, I just made an example that it is working. First I have my DataGrid definition: <asp:DataGrid ID="Grid" runat="server" DataKeyField="DatasetField1" AutoGenerateColumns="False" GridLines="None" OnCancelCommand="Grid_CancelCommand" OnEditCommand="Grid_EditCommand" OnUpdateCommand="Grid_UpdateCommand"> <Columns> <asp:BoundColumn HeaderText="Column1" DataField="DatasetField1"></asp:BoundColumn> <asp:BoundColumn HeaderText="Column2" DataField="DatasetField2"></asp:BoundColumn> <asp:EditCommandColumn EditText="Edit" CancelText="Cancel" UpdateText="Update" HeaderText="Edit"></asp:EditCommandColumn> </Columns> Second I must bind my data grid: public BindData() { .... Grid.DataSource = [MyDataSet With DatasetFi

Categories : C#

Add, Edit DataGrid in WPF
if you have created a database or a list, u can retrieve data and print on the datagrid.. database db = new database (); //database employees emp = new employees (); //list or table in db var result1 = (from t in db.employees select t).ToList(); datagrid1.Itemssource=result1; it prints the data on datagrid

Categories : C#

How to have a DataGrid with two ButtonColumns in it?
Instead of OnSelectedIndexChanged="GradesDataGridSelectedCallback" Use OnItemCommand ="GradesDataGridSelectedCallback" And define your GradesDataGridSelectedCallback as Protected void GradesDataGridSelectedCallback(Object source , DataGridCommandEventArgs e) End Sub Checking e.CommandName would give you indication of which button is clicked.

Categories : C#

Cannot set DataGrid row header value
You should use HeaderText property of Columns collection instead: dataGridView_replaceTable.Columns[0].HeaderText="ROW HEADER 1"; You could also do this when you add your columns by using Caption property: public void addCol() { DataColumn column; column = new DataColumn(string colName); column.DataType = System.Type.GetType("System.String"); column.ColumnName = colName; column.Caption = "My header" // ASSIGN HEADERS HERE column.ReadOnly = false; replaceTableValues.Columns.Add(column); }

Categories : C#

sorting a datagrid with GWT
Apparently my issue was with the fact that I had a keyProvider in both classes, instead of just one. I removed it from the OpInventory class and it seems to work now. this looks like a very specific issue so I expect this question will be closed soon. but I'll leave the code there for future analysis.

Categories : Java

Vi move through DataGrid
If I understand the issue correctly - you have a focus and selection per row. You want to move focus via k/j keys and to toggle selection via x key. I like to use behaviors in these situations - it requires reference to System.Windows.Interactivity.dll from blen SDK but it also makes for a cleaner and modular code. [edit: this is a quick POC that I did. It will probably require some more null reference protection and handling of fringe/edge cases] The behavior is: using System; using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; using System.Windows.Input; using System.Windows.Interactivity; namespace GridNavigationTest { public class GridNavigationBehavior : Behavior<DataGrid> { #region Overrides of Behavior ///

Categories : C#

Get hidden value from wpf datagrid
Rather than trying to read the value out of the Cell, why don't you just pull out the Databound item for your row? if (dgUserEnroll.SelectedItem != null) { var data = (User)dgUserEnroll.SelectedItem; var userID = data.UserId; }

Categories : C#

Opening PDF from a DataGrid
Process.Start("filename") will open a file using the default application on that machine. In most cases, the above approach is correct. It is not dependent on a particular application or particular version of the application being pre-installed on the target machine. The advantage is loose coupling between your application and the PDF viewer. If you really need to, you can use Process.Start() to launch a particular program, many of which will accept a filename as a command line parameter, like so: Process.Start("IExplore.exe", "C:myPathmyFile.htm") (This example taken from the linked MSDN documentation) You can find a list of Adobe Reader's command line arguments here: Adobe Reader Command Line Reference Update: The above link is old (focuses on version 7). You can find version 8 d

Categories : Vb.Net

WPF DataGrid and ITypedList
ICustomTypeDescriptor implementation is required for Row objects. http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/177aef94-62c5-438d-a4a9-8834390559ad

Categories : C#

WPF MVVM DataGrid/Map
Use ObservableCollection for your data source but don't bind to that because that will bind to the default view of your collection, bind both controls to ICollectionView that you control so as you change your collection view in code both controls will update without the need to write any code to sync them... So in your case, when you filter the data, your view that is using TwoWay binding will change and since the map is bound to same view the changes in view will be immediately visible in the map as well...

Categories : Wpf

Can't refresh datagrid
If you see the old value with that type of data binding, it means you don't update the initial source, but only the temporary one (in your case t_KlantenViewSource). Calling Refresh method on the data added by FindResource cause app to reload it from pre-compiled resource, which won't change in this case. In other words, the problem is you use pre-compiled resource On the same time, you fill the dataset with actual data, but your dataset is in memory, view source - inside application file. You can try: binding ItemsSource of the entire datagrid or separate column to the TableAdapter dataset change resource compiling behaviour to Content, thus the app will reload it from external file each time you call Refresh method. ADDITION: You can find a solution for your case, just to save ti

Categories : C#

Triggers in datagrid
I'm not very experienced with DataGrid, so this might not be the best option, but I think you can achieve what you're after by styling the Row, rather than the individual Columns: <DataGrid <!-- Your settings here -->> <!-- Your column definitions here --> <DataGrid.RowStyle> <Style TargetType="DataGridRow"> <Style.Triggers> <DataTrigger Binding="{Binding Path=Errorcode}" Value="0"> <Setter Property="Background" Value="LightGreen" /> <!-- Other Setters --> </DataTrigger> <DataTrigger Binding="{Binding Path=Filename}" Value="File not created"> <

Categories : C#

Checkbox with DataGrid WPF
For an MVVM Solution you could try this: <StackPanel> <DataGrid ItemsSource="{Binding Path=TestItems}" AutoGenerateColumns="False" Name="MyDataGrid" CanUserAddRows="False"> <DataGrid.Columns> <DataGridCheckBoxColumn Binding="{Binding IsSelected}" Width="50" > <DataGridCheckBoxColumn.HeaderTemplate> <DataTemplate x:Name="dtAllChkBx"> <CheckBox Name="cbxAll" Content="All" IsChecked="{Binding Path=DataContext.AllSelected,RelativeSource={RelativeSource AncestorType=DataGrid}}"/> </DataTemplate> </DataGridCheckBoxColumn.HeaderTemplate> </DataGridCheckBoxColumn> <DataGridTe

Categories : Wpf

Button widget to datagrid in GWT
One doesn't add widgets to cell-based widgets. For buttons you have several choices: ActionCell, with a fixed message and using a delegate to react to clicks ButtonCell, whose text can vary for each row (uses the Column's getValue) and using FieldUpdater to communicate clicks TextButtonCell, similar to ButtonCell but uses the appearance pattern (also used by Sencha GXT btw) so you can customize the rendering (default appearance is a native button) For checkboxes, use the CheckboxCell. Depending on whether you're using it to edit a boolean value or to select the rows, you'll use one constructor or the other, and possibly a selection event manager. You'll find examples of use in the Showcase app: Cell Sampler shows you buttons (not the TextButtonCell though) and how to edit a boolean

Categories : Gwt

WPF : DataGrid Get checked columns
you can create the style for your header and update your checkbox like below: <Style x:Key="HeaderStyle" TargetType="{x:Type DataGridColumnHeader}"> <Style.Setters> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type DataGridColumnHeader}"> <CheckBox Command="{Binding DataContext.MyCommand, RelativeSource={RelativeSource AncestorType={x:Type Window}}}" CommandParameter="{TemplateBinding Content}"></CheckBox> </ControlTemplate> </Setter.Value>

Categories : Wpf

Binding an ObservableCollection to a DataGrid
Set the properties you want databound to public public string FileName { get { return fileName; } set { fileName = value; OnPropertyChanged("FileName"); } } public string Path { get; set; } public string Extension { get; set; }

Categories : C#

Extract DataSet from DataGrid
As @HighCore has mentioned, in WPF, we work with data and Binding. We would normally set the ItemsSource property of the DataGrid to our data object like this: dataGrid.ItemsSource = ds.Tables[0]; Therefore, we would normally retrieve the values simply by looking in the ds variable.

Categories : C#

FormatString on WPF-DataGrid has no effect
Here is my solution: I can't simple use FormatString, without binding a datetime. So i wrote an IValueconverter: public class StringDateTimeValueConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { DateTime cOutDateTime = DateTime.Now; if (DateTime.TryParse(value.ToString(), out cOutDateTime)) { return cOutDateTime; } else { return DependencyProperty.UnsetValue; } } public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return value.ToString(); } }

Categories : C#

Link Combobox and datagrid
If you are looking to find a 'selection changed' event for a DataGrid, please take a look at the WPF datagrid selected row clicked event? post here at StackOverflow. In short, you can attach a handler to the DataGridRow.Selected event: <DataGrid ... > <DataGrid.ItemContainerStyle> <Style TargetType="DataGridRow"> <EventSetter Event="MouseDoubleClick" Handler="Row_DoubleClick"/> </Style> </DataGrid.ItemContainerStyle> ... </DataGrid> From the linked post.

Categories : C#

DataGrid export to excel
Maybe in this princip work. String path = @"D:users...."; //your path String connStr = "Provider=//your provider;Data Source=" + path + ";Extended Properties=Excel 12.0;"; //The connection to that file OleDbConnection conn = new OleDbConnection(connStr); //The query string strSQL = "SELECT * FROM [?]"; //The command OleDbCommand cmd = new OleDbCommand(/*The query*/strSQL, /*The connection*/conn); DataTable dT = new DataTable(); conn.Open(); try { OleDbDataReader dR = cmd.ExecuteReader(); dT.Load(dR); bS.DataSource = dT; dGV.DataSource = bS; } catch (Exception

Categories : Vb.Net

WPF C# DataGrid edit cell
Create class with all the properties defined and set/bind the ItemsSource of Datagrid to the list of Data class. public class Data { public string IdZdarzenia {get;set;} public string Gospodarze {get;set;} public string Goście {get;set;} public string Kurs1 {get;set;} public string Kurs0 {get;set;} public string Kurs2 {get;set;} public string Kurs10 {get;set;} public string Kurs20 {get;set;} public string Kurs12 {get;set;} public string DataZdarzenia { get; set; } } Setting ItemSource List<Data> dataSource = new List<Data>(); dataSource.Add(new Data() { IdZdarzenia = "a", Gospodarze = "d", Goście =

Categories : C#

jquery-how to get control by id in datagrid
Try this: var gvTextboxes = $('#<%=GridView1.ClientID %>').find('input:text[id$="TextBox1"]'); var specificTextbox = gvTextBoxes[0]; var specificText = specificTextbox.val(); Replace GridView1, TextBox1 with your control names.

Categories : Jquery

WPF DataGrid, converting value in cell
Create an instance of your converter in XAML and apply it using StaticResource- <DataGrid> <DataGrid.Resources> <local:MyConverter x:Key="MyConverter"/> </DataGrid.Resources> ..... <DataGridTextColumn Binding="{Binding Path=xxx, Mode=OneWay, Converter={StaticResource MyConverter}}" Width="140" Header="Some Header"/> <DataGrid> where local is namespace where your converter resides and declare at top of your XAML - xmlns:local="clr-namespace:YourNamespace" Also you should read on how to implement IValueConverter on your bindings. This link here will be helpful to get you started.

Categories : C#

WPF - Datagrid get new item AFTER editing
It's very simple: // instances of this type user should edit in data grid public class Item : IEditableObject { // the item identifier public int Id { get; set; } // some data-bound properties #region IEditableObject Members public void BeginEdit() { } public void CancelEdit() { } public void EndEdit() { // new items has identifier, set to 0 if (Id == 0) { // post changes here } } #endregion } DataGrid knows about IEditableObject, and if the bound data item implements this interface, grid calls corresponding methods during the editing.

Categories : C#

reading from datagrid writng to sql VIA xml
As the exception says your string is not able to converted back to date time, so it coul dbe either at this stage ActualVisitDateTime = Convert.ToDateTime(ds.Tables[0].Rows[i].ItemArray[6]); Or at this step ScheduledDateTime = Convert.ToDateTime(ds.Tables[0].Rows[i].ItemArray[2]); Have you checked the values ?? why are converting it to datetime when are again converting it to a sql string ??

Categories : C#

DataGrid .Net compact framework
What part don't you understand? class Form2 : Form { private static string SQLCONNECTION = @"Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"; private DataGrid dataGrid1; private void button_Click(object sender, EventArgs e) { var table = LoadData("SELECT FirstName, LastName FROM Employees;"); dataGrid1.DataSource = table; } private DataTable LoadData(string sqlCmd) { var table = new DataTable(); using (var cmd = new SqlCommand(sqlCmd, new SqlConnection(SQLCONNECTION))) { cmd.Connection.Open(); table.Load(cmd.ExecuteReader()); cmd.Connection.Close(); } return table; } }

Categories : C#

Datagrid ComboBox Binding
You need to set the SelectedValuePath value to your variable property. The DisplayMemberPath is for what is shown, and SelectedValuePath is what is selected. SelectedItem is the actual item that is selected.

Categories : Wpf



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.