TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
rachayita jaiswal
NA
217
106.2k
checkbox in gridview
Feb 19 2014 12:00 AM
Hi,
In my gridview i have put checkbox as checked but on button click it is coming as false.
here is my code:
<asp:GridView ID="grdv_rights" runat="server" HorizontalAlign="Center" AllowPaging="true"
CellPadding="5" AutoGenerateColumns="false" Width="100%" PageSize="5" >
<FooterStyle ForeColor="Black" BorderColor="#3D98C1" />
<EmptyDataTemplate>
<asp:Label ID="lblEmptySearch" runat="server" Font-Bold="True" ForeColor="#0033CC">No Results Found....
</asp:Label>
</EmptyDataTemplate>
<Columns>
<asp:TemplateField HeaderText="Sl No" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="50px" >
<ItemTemplate>
<%#Container.DataItemIndex+1%>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField ItemStyle-HorizontalAlign ="Center" DataField="Topic" HeaderText="Survey Topic" />
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="chkSelect" runat="server"/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<RowStyle HorizontalAlign="center" />
<SelectedRowStyle BackColor="gray" ForeColor="Black" />
<PagerStyle Height="10px" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#2E90BD" Font-Names="calibri" Font-Size="11pt" ForeColor="White"
BorderStyle="Solid" BorderWidth="1px" HorizontalAlign="center" />
<AlternatingRowStyle HorizontalAlign="center" />
</asp:GridView>
<asp:Button ID="btn_rights_submit" runat="server" Text="Submit" OnClick="btn_rights_submit_Click" />
------------------
protected void btn_rights_submit_Click(object sender, EventArgs e)
{
try
{
foreach (GridViewRow row in grdv_rights.Rows)
{
CheckBox chk = (CheckBox)row.FindControl("chkSelect");
if (chk.Checked)
{
lbl_user_rights.Text = "test";
}
}
}
catch(Exception ex)
{
obj_db.GetErrorFile("btn_rights_submit_Click", ex.Message);
}
}
please help..
Reply
Answers (
7
)
ListBox SelectedItems to select in the update mode in mvc4
Need Help In Menu Control