So, I have a control with a datagrid in it and I was wondering if depending on the value I get back from the a Request.QueryString if I could set the table name to that (that is the value being sent) and then have it build the columns?
I have about 3 different tables, and they have different amounts of columns, and of course with different names.
Yes you need to access the QueryString collection to get the table name your passing in then just create a new datatable and set its name.
/Create the table and name it/
DataTable dt = new DataTable();
dt.TableName = Request.QueryString[“VariableName”].ToString();
/add the columns/
dt.Columns.Add(Request.QueryString[“VariableName”].ToString(), typeof(String));
dt.Columns.Add(Request.QueryString[“VariableName”].ToString(), typeof(String));
dt.Columns.Add(Request.QueryString[“VariableName”].ToString(), typeof(String));
Enjoy!