Fill gridview checkbox via SQL Server

Asked

Viewed 60 times

1

I have a checkbox in gridview and I want to load fields of type 'bit' in the SQL Server bd at this checkbox, or if it is 'True' the checkbox is 'check.'

I have this:

connect = CONN(un, passwords, db, ip);
String query = "select * from all";
try 
{
    connect = CONN(un, passwords, db, ip);
    Statement statement = connect.createStatement();
    rs = statement.executeQuery(query);
    List<Map<String, String>> data = null;
    data = new ArrayList<Map<String, String>>();
    while (rs.next()) {
        Map<String, String> datanum = new HashMap<String, String>();
        datanum.put("A", rs.getString("a"));
        datanum.put("B", rs.getString("b"));
        datanum.put("C", rs.getString("c"));
        datanum.put("D", rs.getString("d"));
        data.add(datanum);
    }
    String[] from = { "A", "B" , "C", "D" };
    int[] views = { R.id.txtA ,R.id.txtB,R.id.txtC,R.id.txtD};
    final SimpleAdapter ADA = new SimpleAdapter(AMGrid.this,
    data, R.layout.template, from, views);
    gridview.setAdapter(ADA);
} catch (SQLException e) 
{
    e.printStackTrace();
}
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.