dimanche 2 juillet 2017

Checking or unchecking a gridview checkbox dynamically

I have two gridviews, one is on the main page and the other is modal. Both gridviews have one checkbox defined as asp:TemplateField.

What I want is: When I click one checkbox on the modal gridview, all the related checkboxes checked. The code is as follows:

    protected void Secil_CheckedChanged(object sender, EventArgs e)
    {
        int selRowIndex = ((GridViewRow)(((CheckBox)sender).Parent.Parent)).RowIndex;
        CheckBox cb = (CheckBox)GridIller.Rows[selRowIndex].FindControl("Secil");

        if (cb.Checked)
        {
            string secili = HttpUtility.HtmlDecode(GridIller.Rows[selRowIndex].Cells[1].Text);
            foreach (GridViewRow row in GridView1.Rows)
            {
                CheckBox cb1 = (CheckBox)row.FindControl("Sec");
                if (HttpUtility.HtmlDecode(row.Cells[7].Text) == secili)
                {
                    if (row.RowType == DataControlRowType.DataRow)
                    {
                        GridView1.EditIndex = -1;
                        cb1.Checked = true;
                    }

                }
            }
        }

When I debug the program I see that cb1.checked; statement is executing but checkbox in the gridview remains unchecked.




samedi 1 juillet 2017

Unable to use multiple ':nth-child's within a :checked pseudo code with selector in CSS

I am trying to create a dynamic table. The user will select checkboxes that will toggle column headers depending on which checkboxes the user selects. Additionally I am trying to use CSS to generate the first row of blank inputs for the user. The checkboxes don't select columns that are grouped (like even, odd, or first 5, etc) and there is overlap between which columns are displayed after selecting checkboxes 1-4. Here's an example of my code:

<body>
<input type="checkbox" id="checkbox">
<label>checkbox</label>
<table id="table">
    <tr>
        <th>a</th>
        <th>b</th>
        <th>c</th>
        <th>d</th>
    </tr>
</table>
</body>
</html>

And CSS;

/*------------------------Initialize with just checkbox for user selection*/
table th, td
{
   display: none;
}

/*-------------------------Show columns based on user checkbox selection*/
#checkbox:checked ~ 
#table th:nth-child(1)
{
   display: inline-block;
}
#checkbox:checked ~ 
#table th:nth-child(2)
{
   display: inline-block;
}   
#checkbox:checked ~ 
#table th:nth-child(3)
{
   display: inline-block;
}

/*------------------------Generate first row*/

#checkbox:checked ~ 
#table td:nth-child(1)
{
   display: inline-block;
}
#checkbox:checked ~ 
#table td:nth-child(2)
{
   display: inline-block;
}   
#checkbox:checked ~ 
#table td:nth-child(3)
{
   display: inline-block;
}
/*------------------------Drown in wetness*/

Here's the CSS I have read should work, but I haven't been able to get to work:

/*-------------------------Show user specific columns*/
#checkbox:checked ~ 
#table th:nth-child(1),
#table th:nth-child(2),
#table th:nth-child(3)
{
   display: inline-block;
}

/*------------------------Generate first row*/

#checkbox:checked ~ 
#table td:nth-child(1),
#table td:nth-child(2),
#table td:nth-child(3)
{
   display: inline-block;
}

I'm a beginner and if possible I'd like to use CSS for this. However, if there's a more elegant solution with JS or JQuery I'm open to it. The data users enter will be added together based on the header category and I'll need a way to determine which data was entered under a given header.

Thanks in advance for your help.




WPF Textbox.Text, when Checkbox.IsEnabled with Button

i am using WPF and want to create a "Search"-Window (Window2), related to Window1.

The "Search"-Window has to each checkbox at least one textbox and at the end a "Search"-Button. I don´t want to use

namespace PokemonManager{

/// <summary>
/// Interaktionslogik für suchen.xaml
/// </summary>
public partial class suchen : Window
{

    //Werte uebergeben
    //Name
    private string text_name = "";
    public string textName
    {
        get { return text_name; }
    }

    privat void search_click(object sender, RoutedEventArgs e){
        if(check_name.IsChecked == true){
           //do this
        }

for each checkbox, so I want to create a switch-case for each checkbox to say at the end "This checkboxes are checked, so just search with the Textbox.Text related to the checkboxes.

I´ve tried it with this lines

//Suchen-Button
    public void search_Click(object sender, RoutedEventArgs e)
    {

        CheckBox sender_ch = sender as CheckBox;

        if (sender_ch != null)
        {
            switch (sender_ch.Tag)
            {
                case "tag_name":
                    if (search_name.IsChecked == true)
                    {
                        MessageBox.Show("Hi");
                        text_name = txt_name.Text;
                    }
                    break;
             }
        }
}

I´ve tried it with this lines in

private void chechbox_checked(object sender, RoutedEventArgs e)

too, but there is the problem, that the checkbox take the textbox-Value before I entered a text.

Can I get anyhow the text after I checked a checkbox with a switch-case?

Sry, if I didn´t formated the text in the right way. I hope you can help me and you understand my question!




How to get the particular checked checkboxes, generated dynamically in jquery

I have div in which i append dynamic widgets that each contains a checkbox at the toolbar. This checkbox is use to control the widget, therefore i have set a serial numbers which are dynamically set as ids. Each one is unique so i think they are good for ids.

The problem now is how can i retrieve the exact id of the checked checkbox. This returns the id of the last checkbox in the div as it loop uncontrollably.

I have a spinet bellow:

                    for (var i=0; i < sortedIds.length; i++) {

                            $("#batch_schedule_wraper").append("<div class='col-xs-12  col-sm-6 widget-container-col'>"
                                   +"<div class='widget-box widget-color-blue'>"
                                            +"<div class='widget-header'>"
                                                  +"<h5 class='widget-title bigger lighter'>"+sortedIds[i]+"</h5>"
                                                    +"<div class='widget-toolbar'>"
                                                                 +"<div class='ontrol-group'>"
                                                                         +"<div class='checkbox'>"
                                                                                +"<label class='block'>"
                                                                                        +"<input name='form-field-checkbox' type='checkbox' class='ace input-lg remove_widget' id=''/>"
                                                                                        +"<span class='lbl bigger-120'>Batch</span>"
                                                                               +" </label>"
                                                                        +"</div>"                                                                                          
                                                                    +"</div>"
                                                            +"</div>"
                                            +"</div>"
                                            +"<div class='widget-body'>"
                                                    +"<div class='widget-main'>"
                                                        +"<div class='test_list_wraper'></div>"
                                                    +"</div>"
                                            +"</div>"
                                    +"</div>"                               
                            +"</div>");                                                         $("[name='form-field-checkbox']").attr("id",sortedIds[i]);

                    }




Oracle Sql Check Constraint != other table

I want to include a check constraint on a table between the primary key of the latter and the primary key of another table and insert! = Between the two, how can i do it? I've been tempted like this:

CONSTRAINT CK_RE CHECK (ID_RESP =! ID_PR (PR) AND CUSTOMER ID)

But I have not had any positive results




Rendering multiple items with different props React ES6

I am trying to create a field of material ui checkboxes.

I know I could do

<div style=>
      <Checkbox style= checked= onCheck= key={"one"} label={"one"} iconStyle= />
      <Checkbox style= checked= onCheck= key={"two"} label={"two"} iconStyle= />
      .
      .
      .
</div>

for however many checkboxes I need. This however gets annoying and involves a lot of writing.

Therefore I have a CheckboxesFields class which maps Checkboxes based on a prop called labelsList, which contains a list of type String

import React from 'react'
import Checkbox from 'material-ui/Checkbox'
import MuiThemeProvider from 'material-ui/styles/MuiThemeProvider'

const CheckboxesField = props => {
  const checkboxes = props.labelsList.map(label => <Checkbox style= key={label} label={label} iconStyle= />)
    return (
      <MuiThemeProvider>
        <div style=>
          {checkboxes}
        </div>
      </MuiThemeProvider>
    )
  }

export default CheckboxesField

This is then called in App.js

import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import CheckboxesField from './CheckboxesField'

class App extends Component {
  render() {
    return (
      <div className="App">
        <CheckboxesField labelsList={["1", "2", "3", "4", "5"]} />
      </div>
    )
  }
}

export default App
ReactDOM.render(<App />, document.getElementById('root'))

This works but unlike the first example if I pass the props onCheck and checked it will apply to every single checkbox. However I want each checkbox to be controlled individually.

How would I go about doing this?

Thanks for your help.




Show true or false (0/1) from a mySQL in checkbox

<input type="text" id="A1" name="A1">

In the box above, 0 or 1 is placed from mysql (fetch in box). Now I want that:

value box = 0 >> checkbox is unchecked

value box = 1 >> checkbox is checked

How to use a checkbox (type="checkbox") instead of text (type="text")?

<input type="checkbox" id="A1" name="A1">