read array values to textbox

dualshck012

Active member
Joined
Jan 14, 2018
Messages
29
Location
Leyte, Philippines
Programming Experience
1-3
Hello sir, i have a datagridview which displays a patient list according to diagnosis code. The following code must display a patient list according to diagnosis code "A97.0 and A97.1" respectively
i have this code:

C#:
else if (miancmbdiag.SelectedIndex == 4)
{
    string[] dengue_icd = { "A97.0","A97.1"};

    foreach (string intcid in dengue_icd)
    {
        hiddenicdcode.Text = intcid.Substring(0); //A97.0; A97.1
    }

    diag_descrip.Text = "Dengue Fever";
}

But i'm only getting the A97.1 content in my datagridview
 
Last edited by a moderator:
For future reference, please don't trim the whitespace from the first line in your code and not the rest. You just make the code harder to read. If you're not going to trim all the whitespace then don't trim any of it and at least keep the indenting consistent. That said, there's no reason not to trim all of it. You can hold the Alt key while dragging to select an arbitrary rectangular block of text so you can easily trim the leading whitespace from a whole block of code.
 
As for the question, I have no idea what you're actually asking. I see nothing related to a DataGridView in your code. Are you asking how to query a database based on a specific filter? How to filter data that you have already retrieved from a database? Something else?
 
Ok sir, well i have this elseif condition and it works if the textbox value has only one string like from the example code below, but if the value of the textbox contains multiple values, the datagridview can only generate the corresponding data in one of the values. I tried to put them in array but only reading the "A97.1" array string.
C#:
else if (miancmbdiag.SelectedIndex == 3)
            {
                hiddenicdcode.Text = "F31.9";
                diag_descrip.Text = "Bipolar I Disoder";
            }

the code in my combobox event.
C#:
private void maincmbcity_SelectedIndexChanged(object sender, EventArgs e)
        {
                
                try
                {
                    conn.Open();
                    string df = _FromDateTimeRep.Value.ToString("yyyy-MM-dd HH:mm:ss");
                    string dt = _ToDateTimeRep.Value.ToString("yyyy-MM-dd HH:mm:ss");
                    

                    dgtable_dmgrphic.AutoGenerateColumns = true;
                   object  maincmb = maincmbcity.SelectedItem;
                   string query12 = "SELECT hencdiag.diagcode, hadmlog.hpercode as 'HOSPITAL NUMBER', CONCAT (hperson.patlast, ',  ', hperson.patfirst, '  ',hperson.patmiddle) as 'PROFILE', hcity.ctyname as 'DISTRICT', haddr.ctycode as 'CITY CODE', hadmlog.disdate as 'DISCHARGED DATE' FROM hadmlog INNER JOIN hperson ON hadmlog.hpercode=hperson.hpercode INNER JOIN haddr ON hadmlog.hpercode=haddr.hpercode INNER JOIN hencdiag ON hadmlog.enccode=hencdiag.enccode INNER JOIN hcity ON haddr.ctycode=hcity.ctycode WHERE hcity.ctyname = '" + maincmb + "'  AND hencdiag.diagcode ='" + hiddenicdcode.Text + "' AND hencdiag.primediag = 'Y' AND (hadmlog.disdate >= @DateFrom AND hadmlog.disdate <= @DateTo) ORDER BY Profile";

                    cmd = conn.CreateCommand();
                    cmd.CommandType = CommandType.Text;
                    cmd.CommandText = query12;
                    cmd.Parameters.AddWithValue("@DateFrom",df);
                    cmd.Parameters.AddWithValue("@DateTo", dt);
                    adapt = new MySqlDataAdapter(cmd);
                    DataTable dtRecord = new DataTable();
                    adapt.Fill(dtRecord);
                    dgtable_dmgrphic.DataSource = dtRecord;
 
Back
Top Bottom