G
Guest
I have two questions.
1) What is the code to check if datagrid already has a datasource?
When the user clicks "ADD" button I want to add a record to the data grid,
if the user clicks "ADD" again I want another record added to the datagrid.
2) What is the code to get the selected row of the combo box, I need colume
one and three?
Here is my code so far, I get an error message on
(this.dgPrivileges.DataSource == "")
private void cmdAddPrivileges_Click(object sender,
System.EventArgs e)
{
if (this.dgPrivileges.DataSource == "")
{
DataTable dt = new DataTable();
dt.Columns.Add("Code", typeof(string));
dt.Columns.Add("Amount", typeof(float));
this.dgPrivileges.DataSource = dt;
dt.Rows.Add(new object[]{cboPrivilege.Text,
cboPrivilege.Items.IndexOf(1)});
cboPrivilege.Focus();
}
else
{
dt.Rows.Add(new object[]{cboPrivilege.Text});
}
}
1) What is the code to check if datagrid already has a datasource?
When the user clicks "ADD" button I want to add a record to the data grid,
if the user clicks "ADD" again I want another record added to the datagrid.
2) What is the code to get the selected row of the combo box, I need colume
one and three?
Here is my code so far, I get an error message on
(this.dgPrivileges.DataSource == "")
private void cmdAddPrivileges_Click(object sender,
System.EventArgs e)
{
if (this.dgPrivileges.DataSource == "")
{
DataTable dt = new DataTable();
dt.Columns.Add("Code", typeof(string));
dt.Columns.Add("Amount", typeof(float));
this.dgPrivileges.DataSource = dt;
dt.Rows.Add(new object[]{cboPrivilege.Text,
cboPrivilege.Items.IndexOf(1)});
cboPrivilege.Focus();
}
else
{
dt.Rows.Add(new object[]{cboPrivilege.Text});
}
}