homepage Welcome to WebmasterWorld Guest from 23.20.220.61
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
Forum Library, Charter, Moderators: ocean10000

Microsoft IIS Web Server and ASP.NET Forum

    
Can't see gridview id
andrewsmd




msg:4315365
 4:11 pm on May 20, 2011 (gmt 0)

I have a gridview as such



<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CrewId"
BorderStyle="None" GridLines="None" CellPadding="5" DataSourceID="SqlDataSource1">
<HeaderStyle CssClass="callBackHeader" />
<RowStyle CssClass="callBackRow" />
<AlternatingRowStyle BackColor="#EEEEEE" />
<Columns>
<asp:BoundField DataField="Name" SortExpression="Name" HeaderText="Send To" />
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="userCheck" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


I'm trying to loop through it based on a query string. If the query string id matches the row id, then I want to set the checkbox to checked. Right now however, I'm just trying to output the row ID and I can't seem to get it. When I run this, it doesn't write anything. Any ideas why?



' Iterate through the Products.Rows property
For Each row As GridViewRow In GridView1.Rows
Response.Write(row.ID)
'' Access the CheckBox
'Dim cb As CheckBox = row.FindControl("userCheck")
If cb IsNot Nothing AndAlso cb.Checked Then

'Response.Write(row.ID)
' ' First, get the ProductID for the selected row
' Dim leadid As Integer = Convert.ToInt32(GridView1.DataKeys(row.RowIndex).Value)
' Dim sql = "UPDATE Leads SET CalledBack = 'yes' where LeadId = " & leadid
' MyFunctions.executeQuery(sql)

End If 'if cb is not nothing
Next 'for each row

 

bmcgee




msg:4316671
 3:00 am on May 24, 2011 (gmt 0)

Is your code executing before the grid is databound?

Check the value of GridView1.Rows.Count before your loop executes and I suspect it will be 0, meaning no data in the grid yet.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Microsoft / Microsoft IIS Web Server and ASP.NET
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved