-
I’m using datagridview that is connected to table in my database.
I want to change one of the columns in the dgv, because right now, I can see in this columns only the id(fk) of different table (the dgv show only information from first table in sql).
I tried to connect this columns to different table in order to get text instead of the id. -
when I select row from the gridview I want to display in the dropdownlist the item and not the value.
example of code:
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
accountIdTB.Text = accountsDGV.SelectedRow.Cells[1].Text;
AccountTB.Text = accountsDGV.SelectedRow.Cells[3].Text;
phoneTB.Text = accountsDGV.SelectedRow.Cells[4].Text;
webSiteTB.Text = accountsDGV.SelectedRow.Cells[5].Text;
string str = accountsDGV.SelectedRow.Cells[7].Text;
industryDDL.ClearSelection();
industryDDL.DataTextField = str;
}
Can you give us a SQL statement you’re using? Most probably you can easily accomplish this by modifying your SQL query with INNER JOIN to include human readable data from other table instead of showing foreign key ID.
Other option is to use the even you are using above and to query second table every time selected index is updated.
Hope this helps but pls provide more details. SQL statement and/or table structures.