DataGridView issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Marco Pais

    #1

    DataGridView issue

    Hi there.

    I have a DataGridView on a desktop application and it's being filled through
    the use of a Web Service, wich returns a DataSet. The I use
    datagrid.DataSo urce=mydataset. tables[0] to bind the data.
    This dataset contains a table with 4 columns: id, description, status,
    private. Column status can take 4 values, and private, 2 values.

    My question is: how can I make the column status a
    DataGridViewCom boBoxColumn and column private a DataGridViewChe ckBoxColumn?

    I know that, at design time, I can add ComboBox and CheckBox columns, but
    how can I mapp those columns with the data returned by the DataSet, trough
    the web Service?

    Thanks in advance.

    Regards.

    Marco


  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: DataGridView issue

    Marco,

    Can you create a typed instance of the data set in your code which is
    the same as what the server returns (when you created the reference for your
    proxy, it should have created some sort of type which exposes these
    properties properly).

    Using that, you should be able to bind to ^that^ and then configure your
    grid properly.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "Marco Pais" <marco.pais[at]gmail.comwrote in message
    news:%23qZgIZwQ IHA.4880@TK2MSF TNGP03.phx.gbl. ..
    Hi there.
    >
    I have a DataGridView on a desktop application and it's being filled
    through the use of a Web Service, wich returns a DataSet. The I use
    datagrid.DataSo urce=mydataset. tables[0] to bind the data.
    This dataset contains a table with 4 columns: id, description, status,
    private. Column status can take 4 values, and private, 2 values.
    >
    My question is: how can I make the column status a
    DataGridViewCom boBoxColumn and column private a
    DataGridViewChe ckBoxColumn?
    >
    I know that, at design time, I can add ComboBox and CheckBox columns, but
    how can I mapp those columns with the data returned by the DataSet, trough
    the web Service?
    >
    Thanks in advance.
    >
    Regards.
    >
    Marco
    >

    Comment

    • Marco Pais

      #3
      Re: DataGridView issue

      Hi there.

      I worked around using something like this:

      ds = srv.GetData(); // the Web Method of my Web Service

      dgv.AutoGenerat eColumns = false;
      dgv.DataSource = ds.Tables[0];

      DataGridViewTex tBoxColumn TextBoxColumn1 = new
      DataGridViewTex tBoxColumn();
      TextBoxColumn1. HeaderText = "Id";
      TextBoxColumn1. Width = 60;
      TextBoxColumn1. DataPropertyNam e = "id";

      DataGridViewChe ckBoxColumn CheckBoxColumn = new
      DataGridViewChe ckBoxColumn();
      CheckBoxColumn. HeaderText = "Descrição" ;
      CheckBoxColumn. DataPropertyNam e = "estado";

      dgv.Columns.Add (TextBoxColumn1 );
      dgv.Columns.Add (CheckBoxColumn );

      It works!

      Now, I'm having another problem. How can I uptade data via WS again?

      If I used DataAdapter/DataSet, I would be easier. But, in this case, I will
      use a Web Service to update data on database - something like, when I click
      an update button, it will execute:

      srv.UpdateData( data); // srv - my Web Service

      How can I get the data that I edited in DataGridView and update database via
      WS?

      Thanks again.

      Ragards.


      "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c omescreveu
      na mensagem news:OaUjHyxQIH A.5288@TK2MSFTN GP04.phx.gbl...
      Marco,
      >
      Can you create a typed instance of the data set in your code which is
      the same as what the server returns (when you created the reference for
      your proxy, it should have created some sort of type which exposes these
      properties properly).
      >
      Using that, you should be able to bind to ^that^ and then configure
      your grid properly.
      >
      >
      --
      - Nicholas Paldino [.NET/C# MVP]
      - mvp@spam.guard. caspershouse.co m
      >
      "Marco Pais" <marco.pais[at]gmail.comwrote in message
      news:%23qZgIZwQ IHA.4880@TK2MSF TNGP03.phx.gbl. ..
      >Hi there.
      >>
      >I have a DataGridView on a desktop application and it's being filled
      >through the use of a Web Service, wich returns a DataSet. The I use
      >datagrid.DataS ource=mydataset .tables[0] to bind the data.
      >This dataset contains a table with 4 columns: id, description, status,
      >private. Column status can take 4 values, and private, 2 values.
      >>
      >My question is: how can I make the column status a
      >DataGridViewCo mboBoxColumn and column private a
      >DataGridViewCh eckBoxColumn?
      >>
      >I know that, at design time, I can add ComboBox and CheckBox columns, but
      >how can I mapp those columns with the data returned by the DataSet,
      >trough the web Service?
      >>
      >Thanks in advance.
      >>
      >Regards.
      >>
      >Marco
      >>
      >
      >

      Comment

      • Nicholas Paldino [.NET/C# MVP]

        #4
        Re: DataGridView issue

        Marco,

        Well, since you attach the table as the DataSource for the grid, you can
        get the DataTable back from the DataSource and then access the DataSet
        through the DataSet property on the DataTable. Then you can pass that back
        to the service.


        --
        - Nicholas Paldino [.NET/C# MVP]
        - mvp@spam.guard. caspershouse.co m

        "Marco Pais" <marco.pais[at]gmail.comwrote in message
        news:OITjc$xQIH A.3556@TK2MSFTN GP03.phx.gbl...
        Hi there.
        >
        I worked around using something like this:
        >
        ds = srv.GetData(); // the Web Method of my Web Service
        >
        dgv.AutoGenerat eColumns = false;
        dgv.DataSource = ds.Tables[0];
        >
        DataGridViewTex tBoxColumn TextBoxColumn1 = new
        DataGridViewTex tBoxColumn();
        TextBoxColumn1. HeaderText = "Id";
        TextBoxColumn1. Width = 60;
        TextBoxColumn1. DataPropertyNam e = "id";
        >
        DataGridViewChe ckBoxColumn CheckBoxColumn = new
        DataGridViewChe ckBoxColumn();
        CheckBoxColumn. HeaderText = "Descrição" ;
        CheckBoxColumn. DataPropertyNam e = "estado";
        >
        dgv.Columns.Add (TextBoxColumn1 );
        dgv.Columns.Add (CheckBoxColumn );
        >
        It works!
        >
        Now, I'm having another problem. How can I uptade data via WS again?
        >
        If I used DataAdapter/DataSet, I would be easier. But, in this case, I
        will use a Web Service to update data on database - something like, when I
        click an update button, it will execute:
        >
        srv.UpdateData( data); // srv - my Web Service
        >
        How can I get the data that I edited in DataGridView and update database
        via WS?
        >
        Thanks again.
        >
        Ragards.
        >
        >
        "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om>
        escreveu na mensagem news:OaUjHyxQIH A.5288@TK2MSFTN GP04.phx.gbl...
        >Marco,
        >>
        > Can you create a typed instance of the data set in your code which is
        >the same as what the server returns (when you created the reference for
        >your proxy, it should have created some sort of type which exposes these
        >properties properly).
        >>
        > Using that, you should be able to bind to ^that^ and then configure
        >your grid properly.
        >>
        >>
        >--
        > - Nicholas Paldino [.NET/C# MVP]
        > - mvp@spam.guard. caspershouse.co m
        >>
        >"Marco Pais" <marco.pais[at]gmail.comwrote in message
        >news:%23qZgIZw QIHA.4880@TK2MS FTNGP03.phx.gbl ...
        >>Hi there.
        >>>
        >>I have a DataGridView on a desktop application and it's being filled
        >>through the use of a Web Service, wich returns a DataSet. The I use
        >>datagrid.Data Source=mydatase t.tables[0] to bind the data.
        >>This dataset contains a table with 4 columns: id, description, status,
        >>private. Column status can take 4 values, and private, 2 values.
        >>>
        >>My question is: how can I make the column status a
        >>DataGridViewC omboBoxColumn and column private a
        >>DataGridViewC heckBoxColumn?
        >>>
        >>I know that, at design time, I can add ComboBox and CheckBox columns,
        >>but how can I mapp those columns with the data returned by the DataSet,
        >>trough the web Service?
        >>>
        >>Thanks in advance.
        >>>
        >>Regards.
        >>>
        >>Marco
        >>>
        >>
        >>
        >
        >

        Comment

        Working...