Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Below i have grid showing colors



VB
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
       Dim clrname() = {"White", "Yellow Orange", "Sunglow", "Inchworm", "Mountain Meadow", "Fuzzy Wuzzy", "Mahogany"}
       Dim clr() = {"#ffffff", "#ffae42", "#ffcf48", "#b2ec5d", "#30ba8f", "#cc6666", "#cd4a4c"}



       Dim dt As New Data.DataTable
       dt.Columns.Add("Colour")
       For i As Integer = 0 To clr.Length - 1
           dt.Rows.Add(clr(i))
       Next
       GridView1.DataSource = dt
       GridView1.DataBind()


       For i As Integer = 0 To clr.Length - 1
           Dim t As Button = GridView1.Rows(i).FindControl("Button2")
           Dim nm As String = clr(i)
           t.BackColor = Drawing.Color.FromName(nm)
           t.Attributes.Add("OnClick", "return colour(this);")
           t.Text = clrname(i)
       Next

   End Sub


Grid Displaying colors
XML
<asp:GridView ID="GridView1" BorderStyle="solid" BorderColor="black" BorderWidth="1px"  runat="server" AutoGenerateColumns="False">
         <Columns>


             <asp:TemplateField HeaderText="Color">
             <ItemTemplate >

               <asp:Button ID="Button2" style="border:solid 1px black;width:100px;height:30px;cursor:pointer" runat="server" Text="" />
             </ItemTemplate>
             </asp:TemplateField>
         </Columns>


     </asp:GridView>





in Grid textbox i need to display above grid so that i can select color
XML
<asp:GridView ID="GridView2" BorderStyle="solid" BorderColor="black" BorderWidth="1px"  runat="server" AutoGenerateColumns="True">
            <Columns>
            <asp:TemplateField HeaderText="ColorBox">
                <ItemTemplate >
               <asp:TextBox ID="TextBox1"  runat="server" class=""  BorderColor="White" Height="20px" Width="102px"></asp:TextBox>&nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br />

                </ItemTemplate>
                </asp:TemplateField>
            </Columns>


</asp:GridView>
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900