I have a gridview that displays dynimic saved views. So the user will pick a name from the lst which will include the whole sql query to change gridview.
I have attached my code snippet. What I am trying to achieve here, is when selected fields that are selected or in the query would like to display them with a set background colour (as each colour represents a group). Normally this can easily be achieved via HTML side but as it is dynmic and data can be changed at any time, I have no idea how I can do this!
So going by my code, the gridview is inistially hidden, then when a selection is made in the view list box sets the gridview to true and then displays it in the browser.
Now the selected view can be any fields, as these are created and used. So I need to have something that can determine what is the output and set the right background colour to the fields that are chosen that I have pre-defined.
I dont think there is no other way of explaining what I need to do. Any more information regarding what I am trying to do, please let me know.
<asp:GridView ID="GridView1" runat="server" CellPadding="3" DataSourceID="AccessDataSource1"
ForeColor="Black" GridLines="Vertical" BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px">
<FooterStyle BackColor="#CCCCCC" />
<PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="#CCCCCC" />
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/db1.mdb"
SelectCommand="SELECT Name AS Name1, Age AS Age1, Gender AS Gender1 FROM [tblProCom]">
protected void Page_Load(object sender, EventArgs e)
Page.MaintainScrollPositionOnPostBack = true;
protected void lstView_SelectedIndexChanged(object sender, EventArgs e)
this.GridView1.Visible = true;
SQL = "SELECT " + lstView.SelectedValue;
OleDbConnection objConn = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("App_Data/db1.mdb"));
OleDbCommand objCmd = new OleDbCommand(SQL, objConn);
this.AccessDataSource1.SelectCommand = SQL; //use new select query
this.AccessDataSource1.DataBind(); //create new