Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
Collapse
Feed
Dashboard
Wallet
Learn
Achievements
Network
Rewards
SharpGPT
Premium
Contribute
Article
Blog
Video
Ebook
Interview Question
Register
Login
Find Checkbox from GridView in Content Page/Master Page
WhatsApp
Suthish Nair
6y
11.8
k
0
0
25
Blog
.aspx
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"MainContent"
runat
=
"Server"
>
<
asp:GridView
ID
=
"GridView1"
runat
=
"server"
>
<
Columns
>
<
asp:TemplateField
>
<
ItemTemplate
>
<
asp:CheckBox
ID
=
"chkID"
runat
=
"server"
/>
</
ItemTemplate
>
</
asp:TemplateField
>
</
Columns
>
</
asp:GridView
>
</
asp:Content
>
code behind
Dim
ChkSel
As
New
CheckBox
Dim
CellValue
As
New
StringCollection
Dim
tmpGV
As
New
GridView
tmpGV = FindControlRecursive(Page.Master,
"GridView1"
)
For
i = 0
To
tmpGV.Rows.Count - 1
ChkSel =
DirectCast
(
DirectCast
(tmpGV.Rows(i), GridViewRow).Cells(0), TableCell).Controls(1)
If
ChkSel.Checked =
True
Then
CellValue.Add(
DirectCast
(tmpGV.Rows(i), GridViewRow).Cells(1).Text)
End
If
Next
private Control FindControlRecursive(Control root, string id)
{
if (root.ID == id)
{
return root;
}
foreach (Control c in root.Controls)
{
Control t = FindControlRecursive(c, id);
if (t != null)
{
return t;
}
}
return null;
}
Checkbox
GridView
Up Next
Passing Array to Javascript from ASP.NET page
Ebook Download
View all
Printing in C# Made Easy
Read by 22.3k people
Download Now!
Learn
View all
Membership not found