Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

DynamicallyPopulateGridView\Matrix

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
gh - 25 Apr 2008 16:50 GMT
I am using VS 2008.  I have a SqlDataAdapter that returns the Names of
the 50 states and a unique id for each state.   I have a Grid View with
6 columns defined as template fields, the markup is below.  As I load
each state name into a cell I check to see if there are active members
in that state and put an image in the cell before the state name.  Each
state name is also a hyperlink I attach the unique id to.  The grid view
is 20 rows.  When I get to row 20 then I will start at the top in row 0
column 2.

How can I get hold of the row\cell, to set the image url and name
hyperlink?  I have created html tables dynamically before and added the
cells and rows at runtime, but the client would rather I use a html
table or gridview with the rows and columns preset.

TIA

 <asp:GridView ID="gvStates" runat="server" AutoGenerateColumns="False"
            PageSize="20" ShowHeader="False" Width="535px">
            <Columns>
                <asp:TemplateField>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1"
runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Image ID="Image1" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="" Text=""></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2"
runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Image ID="Image2" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink2" runat="server"
NavigateUrl="" Text=""></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox3"
runat="server"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Image ID="Image3" runat="server" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:HyperLink ID="HyperLink3" runat="server"
NavigateUrl="" Text=""></asp:HyperLink>
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>
Stan - 26 Apr 2008 11:16 GMT
> I am using VS 2008.  I have a SqlDataAdapter that returns the Names of
> the 50 states and a unique id for each state.   I have a Grid View with
[quoted text clipped - 62 lines]
>              </Columns>
>          </asp:GridView>

Use the e parameter of the RowDataBound event handler to retrieve a
DataRow as follows:

DataRow drState = (DataRow)e.Row.DataItem;

Then access the data values with drState["ColumnName"] etc

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.