Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: VB.NET
Below i have grid showing colors
 

 
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
<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
<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 26-Apr-13 0:10am

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

  Print Answers RSS
0 OriginalGriff 587
1 Sergey Alexandrovich Kryukov 479
2 Maciej Los 305
3 Mathew Soji 195
4 Richard MacCutchan 145
0 OriginalGriff 7,356
1 Sergey Alexandrovich Kryukov 6,712
2 DamithSL 5,461
3 Manas Bhardwaj 4,916
4 Maciej Los 4,475


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 26 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100