Welcome to WebmasterWorld Guest from 54.226.2.31

Forum Moderators: ocean10000

Message Too Old, No Replies

Can't see gridview id

     

andrewsmd

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

WebmasterWorld Senior Member 5+ Year Member



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

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

10+ Year Member



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.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month