0
It’s been so long since I’ve worked with Winforms, I’m missing something. In my Form Load I call this method below:
private void CarregarEstados()
{
cboEstado.DataSource = Listas.ListaEstados();
cboEstado.DisplayMember = "UF";
}
public static DataTable ListaEstados()
{
DataTable _table = null;
try
{
var _connector = GetSQLInstance.getInstance();
_table = _connector.GetTable(CommandType.StoredProcedure, "SPL_CREDENCIADOS_UF_PESQUISA");
}
catch (Exception Error)
{
LastErrorCode = MazeFire.ErrorManager.GetErrorCode(Error);
LastErrorObject = Error;
LastError = Error.Message;
}
return _table;
}
The called method returns a Datatable with a column called UF. He carries the combo smoothly.
However, I was asked to automatically upload the Cities and Neighborhoods that are available in the BD. So, I do this in the event below:
private void cboEstado_SelectedIndexChanged(object sender, EventArgs e)
{
// Assim o Combo sempre retorna vazio
CarregarCidades(cboEstado.SelectedText);
}
private void CarregarCidades(string estado)
{
cboCidade.DataSource = Listas.ListaCidades(estado);
cboCidade.DisplayMember = "Cidade";
}
My problem occurs when calling the Loadings, because I can’t get the set value in the state (in the SP case).
There in the example is as cboEstado.SelectedText
which passes "" to the method, but I’ve tried cboEstado.SelectedValue.ToString()
and cboEstado.SelectedItem.ToString()
and both pass by System.Data.DataRowView
as a parameter.
Could you explain to me what I’m missing?
Thank you.
And your method
Listas.ListaCidades(estado);
? How are you?– Roberto de Campos
I will edit above.. I put the Liststatus.. the Listcity and the Listneighborhood are the same in structure
– Daniel Afonso
@Danielafonso, It is not necessary for you to put solved in the title of the question. And it is not correct for you to present your answer in it too. Whether you should accept one of the proposals as a response or post your solution as a response and mark it yourself.
– Leandro Angelo
@Leandroangelo sorry about that! I’m new here and I’m still understanding how it works. I’ll fix.
– Daniel Afonso