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
Prakash Mondal
NA
288
210k
How to Check property of CheckBox in GridView within MastePa
May 30 2014 9:40 AM
How to Check property of CheckBox Field in GridView within a
Master Page
??
Design(Master.master):
Master.master(Source View):
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<asp:ContentPlaceHolder id="head" runat="server">
</asp:ContentPlaceHolder>
<style type="text/css">
.style1
{
width: 100%;
}
</style>
<body>
<form id="form1" runat="server">
<div>
<table class="style1">
<tr>
<td>
</td>
<td colspan="3">
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<tr>
<td>
</td>
<td colspan="2">
<asp:Panel ID="Panel1" runat="server">
<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Operation">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Day">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("DayName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<br />
<asp:Button ID="Button9" runat="server" onclick="Button9_Click" Text="Button" />
</asp:Panel>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Default2.aspx (Design View):
Default2.aspx (Source View):
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table class="style1">
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
</asp:Content>
MasterPage.master.cs (Code View)
:
protected void Page_Load(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("Select *from Day", con);
DataTable dt = new DataTable();
da.Fill(dt);
con.Close();
GridView1.DataSource = dt;
GridView1.DataBind();
}
protected void Button9_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvrow in GridView1.Rows)
{
CheckBox chk = (CheckBox)gvrow.FindControl("CheckBox1");
if (chk != null && chk.Checked)
{
}
}
}
Run Default2.aspx:
After Click This "Button" then.....
OutPut:(with Break point on Master.master Page)
But I already Checked CheckBox1 on Default2 Page. Here all time show
Checked=false
.
So, How to Check property of
CheckBox is Tru
e
/False
Properly based on user in GridView within a Master Page??
Please Solve this Problem....
Reply
Answers (
2
)
drop down list to gridview
what is entity framework,ado.net entity data model,linqtosql