Hello, all. I'm having a problem getting the GridView.AutoGenerateEditButton property to do anything for me. Right now, I set it to true, and I don't even get the button added to my GridView, so obviously I can't even get any further to code the actual events. Here is what I have so far (sorry for the messy code; I'm getting close to my deadline and it's been a bit frantic):
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = cmd;
using(SqlDataReader dr = cmd.ExecuteReader())
{
DataSet ds1 = new DataSet();
DataTable dt1 = ds1.Tables.Add("Specs 1");
if (dt1.Rows.Count == 0)
{
ds1.Tables["Specs 1"].Columns.Add("General Information");
ds1.Tables["Specs 1"].Columns.Add("Customer Name");
ds1.Tables["Specs 1"].Columns.Add("Address");
// etc.
}
while (dr.Read())
{
DataRow newRow = ds1.Tables["Specs 1"].NewRow();
int x = 0;
foreach (DataColumn thisColumn in ds1.Tables["Specs 1"].Columns)
{
newRow[ds1.Tables["Specs 1"].Columns[x]] = Convert.ToString(dr[x]);
x += 1;
}
ds1.Tables["Specs 1"].Rows.Add(newRow);
}
DataSet flipped_ds1 = FlipDataSet(ds1); // Flips the dataset's orientation.
Then, when it's time for me to add the GridView to the page, I use the following code:
GridView outputGrid1 = new GridView();
outputGrid1.ShowHeader = false; // Remove the integer headings.
outputGrid1.DataSource = flipped_ds1;
outputGrid1.DataBind();
outputGrid1.AutoGenerateEditButton = true;
Controls.Add(outputGrid1);
Now, the columns are being added exactly the way that I want, and the data is populating properly. However, I don't have the edit buttons that I assume I should have by setting the GridView.AutoGenerateEditButton property to true. I'm sure I'm missing something simple; can someone help? Thanks very much.