Click here to Skip to main content
15,891,657 members

Comments by bhavikadb (Top 26 by date)

bhavikadb 9-Mar-18 6:53am View    
Can you give some example links for the same? and also do i need to have VS2015 and Above or any VS will work
bhavikadb 2-Aug-16 2:31am View    
Query string is not secure and need to pass a clear text.
bhavikadb 30-Jun-16 7:26am View    
Thanks you RickZeeland for the solution. I got a solution earlier but now I'm stuck between event handling for a comboboxcolumn as I have two comboboxcolumn in a grid.

What I Have tried is:

private void dgvArtWork_EditingControlShowing(object sender, DataGridViewEditingControlShowingEventArgs e)
{
if (dgvArtWork.CurrentCell.ColumnIndex == 14 && e.Control is ComboBox)
{
ComboBox comboBox = e.Control as ComboBox;
comboBox.SelectedIndexChanged += adColumnComboSelectionChanged;

}
else if (dgvArtWork.CurrentCell.ColumnIndex == 16 && e.Control is ComboBox)
{
ComboBox comboBox = e.Control as ComboBox;
comboBox.SelectedIndexChanged += logoColumnComboSelectionChanged;

}
}

private void adColumnComboSelectionChanged(object sender, EventArgs e)
{
var currentcell = dgvArtWork.CurrentCellAddress;
var sendingCB = sender as DataGridViewComboBoxEditingControl;
DataGridViewComboBoxCell cel = (DataGridViewComboBoxCell)dgvArtWork.Rows[currentcell.Y].Cells[16];
DataGridViewComboBoxCell celAD = (DataGridViewComboBoxCell)dgvArtWork.Rows[currentcell.Y].Cells[14];
DataTable dsMaster = new DataTable();

string item = dgvArtWork.Rows[currentcell.Y].Cells[5].Value.ToString();
string size = dgvArtWork.Rows[currentcell.Y].Cells[6].Value.ToString();
string ad = sendingCB.EditingControlFormattedValue.ToString();
//string ad = dgvArtWork.Rows[currentcell.Y].Cells[14].FormattedValue.ToString();

cn.Open();
SqlDataAdapter adp = new SqlDataAdapter("Select Logo from ArtWorkMaster where CustCode='" + txtCustCode.Text + "' and AD='" + ad + "' and item='" + item + "' and size='" + size + "'", cn);
adp.Fill(dsMaster);
adp.Dispose();
cn.Close();

for (int i = 0; i < dsMaster.Rows.Count; i++)
{
cel.Items.Add(dsMaster.Rows[i].ItemArray[0]);
}
}

private void logoColumnComboSelectionChanged(object sender, EventArgs e)
{
var currentcell = dgvArtWork.CurrentCellAddress;
var sendingCB = sender as DataGridViewComboBoxEditingControl;
//DataGridViewComboBoxCell cel = (DataGridViewComboBoxCell)dgvArtWork.Rows[currentcell.Y].Cells[18];
//DataGridViewComboBoxCell celAD = (DataGridViewComboBoxCell)dgvArtWork.Rows[currentcell.Y].Cells[14];
DataTable dsMaster = new DataTable();

string item = dgvArtWork.Rows[currentcell.Y].Cells[5].Value.ToString();
string size = dgvArtWork.Rows[currentcell.Y].Cells[6].Value.ToString();
string ad = dgvArtWork.Rows[currentcell.Y].Cells[14].Value.ToString();
string logo = sendingCB.EditingControlFormattedValue.ToString();

cn.Open();
SqlDataAdapter adp = new SqlDataAdapter("Select Logo from ArtWorkMaster where CustCode='" + txtCustCode.Text + "' and AD='" + ad + "' and item='" + item + "' and size='" + size + "'", cn);
adp.Fill(dsMaster);
adp.Dispose();
cn.Close();
}

The problem is whenever I select a item from any combobox it fires both the event.

Please can you help we with it
bhavikadb 18-Dec-15 5:33am View    
Added Example and Expected Result
bhavikadb 18-Dec-15 5:27am View    
it has password field as well but I have only written needed columns for query