Welcome to WebmasterWorld Guest from 54.147.134.218

Forum Moderators: ocean10000

Message Too Old, No Replies

Can't see gridview id

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

Senior Member

WebmasterWorld Senior Member 5+ Year Member

joined:June 10, 2008
posts: 1130
votes: 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
3:00 am on May 24, 2011 (gmt 0)

Full Member

10+ Year Member

joined:May 14, 2001
posts:262
votes: 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.
 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members