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
Kranthi Vardhan Kolluru
1.2k
512
48.7k
Nested Gridview button click event
Aug 16 2017 1:09 AM
<html xmlns=
"http://www.w3.org/1999/xhtml"
>
<head runat=
"server"
>
<title></title>
<style>
.GrowStyle
{
padding: 0px;
margin: 0px;
}
.leftpnl
{
padding: 10px;
background-color: #cad5e2;
height: 250px;
border-radius: 10px;
}
.rightpnl
{
padding: 10px;
}
.divHead
{
border-radius: 10px;
background-color: #333;
}
.tableR
{
padding: 0px;
margin: 0px;
}
.tableR td
{
}
.divRes_Panel
{
padding: 5px;
}
.TabelRes_Panel
{
background-color: #fff;
/*box-shadow: 1px 1px 1px #888888;*/
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: rgba(0,0,0,0.7) 1px 1px 2px;
-moz-box-shadow: 1px 1px 2px #ddd;
box-shadow: rgba(0,0,0,0.7) 1px 1px 2px;
padding: 20px;
}
.TabelRes_Panel td
{
padding: 5px;
padding-left: 10px;
}
.TabelRes_Panel_Head
{
border-radius: 5px 5px 0 0;
background-color: #333;
color: #fff;
}
.Head
{
background-color: #e5ecf5;
padding: 5px;
}
.Body
{
background-color: transparent;
}
</style>
<script src=
"https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"
type=
"text/javascript"
></script>
<script language=
"javascript"
type=
"text/javascript"
>
function expandcollapsesub(obj, row) {
var div = document.getElementById(obj);
var img = document.getElementById(
'img'
+ obj);
if
(div.style.display ==
"none"
) {
$(div).slideToggle();
div.style.display =
"block"
;
//SHOW
if
(row ==
'alt'
) {
img.src =
"images/minus.png"
;
}
else
{
img.src =
"images/minus.png"
;
}
img.alt =
"Close to view other Customers"
;
// return false;
}
else
{
$(div).slideUp();
// div.style.display = "none"; //HIDE
if
(row ==
'alt'
) {
img.src =
"images/plus.png"
;
}
else
{
img.src =
"images/plus.png"
;
}
img.alt =
"Expand to show Orders"
;
// return false;
}
}
</script>
</head>
<body>
<form id=
"form1"
runat=
"server"
>
<cc1:ToolkitScriptManager ID=
"scrimngr"
runat=
"server"
>
</cc1:ToolkitScriptManager>
<div>
<asp:UpdatePanel ID=
"updatePanel1"
runat=
"server"
>
<Triggers>
<asp:PostBackTrigger ControlID=
"chkAllQues"
/>
<asp:PostBackTrigger ControlID=
"btnshow1"
/>
<asp:PostBackTrigger ControlID=
"grdQues"
/>
</Triggers>
<ContentTemplate>
<div
class
=
"col-lg-12"
>
<div
class
=
"rightpnl"
>
<div
class
=
"table-responsive"
>
<table
class
=
"table divHead tableR"
style=
"padding: 0px; margin-top: 20px; width: 100%"
>
<tr>
<td width=
"5%"
style=
"color: #f3f3f3; padding: 10px;"
>
<asp:LinkButton ID=
"lnkBack"
runat=
"server"
ForeColor=
"#f3f3f3"
Font-Underline=
"false"
ToolTip=
"Back"
class
=
"fa fa-2x fa-chevron-circle-left"
>
</asp:LinkButton>
</td>
<td width=
"95%"
style=
"border-top: 0px solid #fff"
>
<asp:Label ID=
"lblSurTitle"
runat=
"server"
ForeColor=
"#54bbe7"
Text=
""
Font-Size=
"25px"
></asp:Label><br />
<asp:Label ID=
"lbltitle"
runat=
"server"
ForeColor=
"#54bbe7"
Text=
""
></asp:Label>
</td>
</tr>
<tr>
<td style=
"background-color: #cad5e2; color: #333; padding: 0px; margin: 0px;"
colspan=
"2"
>
<div style=
"padding: 0px; margin: 0px;"
>
<%--#f3f3f3--%>
<div
class
=
"pull-left"
style="text-wrap: normal; background-color: #fdfdfd; border-radius: 5px 5px 0 0;
padding: 5px; margin-top: 10px; margin-left: 10px; text-align: center;">
<div
class
=
"fa fa-2x fa-bar-chart"
>
</div>
<asp:LinkButton ID=
"QS"
Width=
"100px"
runat=
"server"
Text=
"Question Summaries"
Font-Underline=
"false"
Font-Bold=
"true"
ForeColor=
"Black"
></asp:LinkButton></div>
<%--<div
class
=
"pull-left"
style=
"text-wrap:normal; background-color:#fff; border-radius:5px 5px 0 0; padding:5px; margin-top:10px; margin-left:10px; text-align:center;"
>
<asp:LinkButton ID=
"DT"
runat=
"server"
Text=
"Data Trends"
Font-Underline=
"false"
Font-Bold=
"false"
></asp:LinkButton></div>
<div
class
=
"pull-left"
style=
"text-wrap:normal; background-color:#fff; border-radius:5px 5px 0 0; padding:5px; margin-top:10px; margin-left:10px; text-align:center;"
>
<asp:LinkButton ID=
"IR"
runat=
"server"
Text=
"Individual Responses"
Font-Underline=
"false"
Font-Bold=
"false"
></asp:LinkButton></div>--%>
</div>
</td>
</tr>
<tr>
<td style="background-color: #fdfdfd; border-top: 0px solid #f3f3f3; padding: 15px;
width: 40%;
" colspan="
2">
<div style=
"width: 200px; background-color: skyblue"
>
<a href=
"javascript:expandcollapsesub('div<%# Eval("
slno
") %>', 'one');"
style="font-weight: 600;
color: #000;">
<img id=
"imgdiv<%# Eval("
slno
") %>"
alt=
"Click to show/hide Response <%# Eval("
slno
") %>"
border=
"0"
src=
"Images/plus.png"
/><b style=
"background-color: skyblue"
>CUSTOMERS LIST</b></a>
</div>
<div id=
"div<%# Eval("
slno
") %>"
style="display: none; background-color: #ffffff;
border: 2px solid skyblue; position: relative; left: 0px; overflow: auto; width: 20%;
padding: 10px;">
<asp:CheckBox ID=
"chkAllQues"
runat=
"server"
Checked=
"true"
AutoPostBack=
"true"
OnCheckedChanged=
"chkAllQues_CheckedChanged"
Text=
"Select All"
/>
<asp:Panel runat=
"server"
ID=
"Panel1"
ScrollBars=
"Vertical"
Height=
"200px"
>
<asp:GridView ID=
"grdQues"
runat=
"server"
AutoGenerateColumns=
"false"
SkinID=
"myGreen"
ShowFooter=
"true"
Width=
"100%"
OnRowDataBound=
"grdQues_RowDataBound"
>
<Columns>
<asp:TemplateField HeaderText=
" "
>
<ItemTemplate>
<asp:CheckBox ID=
"chkIsQues"
runat=
"server"
Checked=
"true"
/>
</ItemTemplate>
<ItemStyle Width=
"5%"
/>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID=
"lblQID"
runat=
"server"
Text=
'<%#Eval("slno") %>'
></asp:Label>
</ItemTemplate>
<ItemStyle Width=
"1%"
/>
</asp:TemplateField>
<asp:TemplateField HeaderText=
"Questions"
>
<ItemTemplate>
<asp:Label ID=
"lblDesc"
runat=
"server"
Text=
'<%#Eval("name") %>'
></asp:Label>
<asp:Label ID=
"lblSDQuesId"
runat=
"server"
Text=
'<%#Eval("slno") %>'
Visible=
"false"
></asp:Label>
</ItemTemplate>
<ItemStyle Width=
"94%"
/>
</asp:TemplateField>
<asp:TemplateField>
<FooterTemplate>
<asp:Button ID=
"btnS"
runat=
"server"
OnClick=
"btnshow_Click"
Text=
"ShowUp"
/>
</FooterTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle />
</asp:GridView>
</asp:Panel>
<br />
<asp:UpdatePanel ID=
"Updatepanel2"
runat=
"server"
>
<ContentTemplate>
<asp:Button ID=
"btnshow1"
runat=
"server"
Text=
"Show Report"
CssClass=
"btn"
BorderStyle=
"Double"
BorderColor=
"#f2f2f2"
ForeColor=
"#ffffff"
Font-Bold=
"true"
OnClientClick=
"return btnshow_Click;"
BorderWidth=
"5"
Style="padding: 8px; border-radius: 5px; background-color: #54bbe7;
color: #323232;" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</td>
</tr>
<tr>
<td>
<asp:Label ID=
"lblmsg"
runat=
"server"
ForeColor=
"Red"
></asp:Label>
</td>
</tr>
</table>
</div>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
code behind is
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!IsPostBack)
{
BindGrid();
}
}
void
BindGrid()
{
DataTable dt =
new
DataTable();
DataRow dr =
null
;
dt.Columns.Add(
new
DataColumn(
"slno"
,
typeof
(
string
)));
dt.Columns.Add(
new
DataColumn(
"Name"
,
typeof
(
string
)));
dt.Columns.Add(
new
DataColumn(
"Access"
,
typeof
(
string
)));
dr = dt.NewRow();
dr[
"slno"
] = 1;
dr[
"Name"
] =
"kranthi"
;
dr[
"Access"
] =
string
.Empty;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[
"slno"
] = 2;
dr[
"Name"
] =
"RAVI"
;
dr[
"Access"
] =
string
.Empty;
dt.Rows.Add(dr);
dr = dt.NewRow();
dr[
"slno"
] = 3;
dr[
"Name"
] =
"SASI"
;
dr[
"Access"
] =
string
.Empty;
dt.Rows.Add(dr);
ViewState[
"DT"
] = dt;
grdQues.DataSource = dt;
grdQues.DataBind();
}
protected
void
btnshow_Click(
object
sender, EventArgs e)
{
//strMultiQues = string.Empty;
//foreach (GridViewRow grdrowitem in grdQues.Rows)
//{
// CheckBox chkIsQues = (CheckBox)grdrowitem.FindControl("chkIsQues");
// if (chkIsQues.Checked)
// {
// Label lblSDQuesId = (Label)grdrowitem.FindControl("lblSDQuesId");
// strMultiQues = strMultiQues + lblSDQuesId.Text + ",";
// }
//}
//GetResponseData();
lblmsg.Text =
"Button click event!!"
;
}
protected
void
grdQues_RowDataBound(
object
sender, GridViewRowEventArgs e)
{
if
(e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Attributes.Add(
"onmouseover"
,
"this.originalstyle=this.style.backgroundColor;this.style.backgroundColor='#EEFFAA';this.style.cursor = 'pointer';"
);
e.Row.Attributes.Add(
"onmouseout"
,
"this.style.backgroundColor=this.originalstyle;this.style.cursor = 'pointer';"
);
}
}
protected
void
chkAllQues_CheckedChanged(
object
sender, EventArgs e)
{
if
(chkAllQues.Checked)
{
foreach
(GridViewRow grdrowitem
in
grdQues.Rows)
{
CheckBox chkIsQues = (CheckBox)grdrowitem.FindControl(
"chkIsQues"
);
chkIsQues.Checked =
true
;
}
}
else
{
foreach
(GridViewRow grdrowitem
in
grdQues.Rows)
{
CheckBox chkIsQues = (CheckBox)grdrowitem.FindControl(
"chkIsQues"
);
chkIsQues.Checked =
false
;
}
}
}
My problem is when i click on button or select checkbox or any other event the nested grid isdclosing automatically. i want to rise the events if the nested grid is in expand state that would be in expand state only when the button click event raise. I think the Javascript is runnig automatically on every event fired. please help
Reply
Answers (
2
)
how i can upload multipal file upload in asp.net ?
datatable datakeys