How to get this DataList with the paging property? - c#

I am a new ASP.NET developer and I am developing a web-based application in which I have a DataList and I need to have a paging feature. I followed what is explained in this post in the CodeProject, but it did not work with me and I got this error which I could not be able to understand it.
Error:
The name 'CurrentPage' does not exist in the current context.
So how to fix this error and get the Paging feature in this DataList?
ASP.NET code:
<tr>
<td width="100%">
<asp:DataList ID="DataList1" runat="server" DataSourceID="SqlDataSource2" >
<ItemTemplate>
<asp:HyperLink
ID="HyperLink1" runat="server" NavigateUrl='<%# "StartQuiz.aspx?testid=" + Eval("QuizID") %>'
Text='<%# Eval("Title") %>'></asp:HyperLink><br />
<asp:Label
ID="DescriptionLabel" runat="server" CssClass="generaltext" Text='<%# Eval("Description") %>'></asp:Label> <br />
<br />
</ItemTemplate>
</asp:DataList>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:testConnectionString %>"
SelectCommand="SELECT [Title], [Description], [QuizID],[IsSent] FROM [Quiz] where [IsSent]=1 order by [QuizID] DESC">
</asp:SqlDataSource>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblCurrentPage" runat="server" Visible="true"></asp:Label>
</td>
</tr>
<tr>
<td align="center">
<asp:Button ID="cmdPrev" runat="server" Text=" << " OnClick="cmdPrev_Click" />
<asp:Button ID="cmdNext" runat="server" Text=" >> " OnClick="cmdNext_Click" />
</td>
</tr>
Code-Behind:
protected void items()
{
PagedDataSource objDs = new PagedDataSource();
DataView dv = (DataView)SqlDataSource2.Select(DataSourceSelectArguments.Empty);
objDs.DataSource = dv;
objDs.AllowPaging = true;
objDs.PageSize = 5;
objDs.CurrentPageIndex = CurrentPage;
lblCurrentPage.Text = "Page:" + (CurrentPage + 1).ToString() + " Of " + objDs.PageCount.ToString();
cmdPrev.Enabled = !objDs.IsFirstPage;
cmdNext.Enabled = !objDs.IsLastPage;
DataList1.DataSource = objDs;
DataList1.DataBind();
}
protected void cmdPrev_Click(object sender, EventArgs e)
{
try
{
CurrentPage -= 1;
items();
}
catch (Exception ex)
{
Logger.LogException(ex);
}
}
protected void cmdNext_Click(object sender, EventArgs e)
{
try
{
CurrentPage += 1;
items();
}
catch (Exception ex)
{
Logger.LogException(ex);
}
}

Declare "CurrentPage variable at the Top of everything" i believe in your case it should be int CurrentPage = 1;

Related

Copy a ListView and show it on a new page

I am trying to copy a ListView from one class to another and show that ListView on a new aspx page. What I am doing is I am selecting certain values from the first ListView and only those items will be shown on a new page. However, I can't figure out how to show the ListView on a new page because I am used to using a SqlDataSource. I am passing the ListView through the addList method and I have already created a new ListView in the new aspx file.
Please let me know the best way to handle this and if I need to add more information.
Code in First Class
public void CloneButton_Click(object sender, EventArgs e)
{
String droplist = DropDownList2.SelectedValue;
list = new ListView();
if (String.IsNullOrEmpty(droplist))
{
ScriptManager.RegisterStartupScript(this, GetType(), "error", "alert('Please select a Program Name and Report Period');", true);
return;
}
else
{
if (ListView1.Items.Count == 0)
{
Button1_Click(sender, e);
}
else
{
var selectAllCheckBox = (CheckBox)ListView1.InsertItem.FindControl("CheckBox2");
if (selectAllCheckBox.Checked == true)
{
list = ListView1;
Response.Redirect("~/CloneReport.aspx");
return;
}
for (int i = 0; i < ListView1.Items.Count; i++)
{
CheckBox chk = (CheckBox)ListView1.Items[i].FindControl("CheckBox1");
if (chk.Checked == true)
{
list.Items.Add(ListView1.Items[i]);
}
}
CloneReport rep = new CloneReport();
rep.addList(list);
Response.Redirect("~/CloneReport.aspx");
}
}
}
Code in Second Class
public void addList(ListView list)
{
ListView1 = new ListView();
for (int i = 0; i < list.Items.Count; i++)
{
ListView1.Items.Add(list.Items[i]);
}
ListView1.DataBind();
}
ListView Item Template From Old Page(Page Im transferring from)
<ItemTemplate>
<tr style="background-color: #E0FFFF; color: #333333;">
<td>
<asp:CheckBox ID="CheckBox1" runat="server" />
</td>
<td>
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" />
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" />
</td>
<td>
<asp:Label ID="FormTitleLabel" runat="server" Text='<%# Eval("FormTitle") %>' />
</td>
<td>
<asp:Label ID="FormSectionLabel" runat="server" Text='<%# Eval("FormSection") %>' />
</td>
<td>
<asp:Label ID="SubSectionLabel" runat="server" Text='<%# Eval("SubSection") %>' />
</td>
<td>
<asp:Label ID="SectionItemLabel" runat="server" Text='<%# Eval("SectionItem") %>' />
</td>
<td>
<asp:Label ID="SortOrder" runat="server" Text='<%# Eval("SortOrder") %>' />
</td>
<td>
<asp:Label ID="SectionSortOrder" runat="server" Text='<%# Eval("SectionSortOrder") %>' />
</td>
<td>
<asp:Label ID="SubSectionSortOrder" runat="server" Text='<%# Eval("SubSectionSortOrder") %>' />
</td>
<td>
<asp:Label ID="RuleDesc" runat="server" Text='<%# Eval("RuleDesc") %>' />
</td>
<td>
<asp:Label ID="ControlType" runat="server" Text='<%# Eval("ControlType") %>' />
</td>
<td>
<asp:Label ID="CrossItem" runat="server" Text='<%# Eval("CrossItem") %>' />
</td>
</tr>
</ItemTemplate>
Triggers for Update Panel
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownList1" />
<asp:AsyncPostBackTrigger ControlID="Button1" />
<asp:AsyncPostBackTrigger ControlID="CloneButton" />
</Triggers>
<ContentTemplate>
<div style="text-align: center;">
<asp:Button ID="CloneButton" runat="server" Text="Clone Report Period" OnClick="CloneButton_Click" />
</div>
<div style="text-align: center; position: absolute; margin-left: auto; margin-right: auto; left: 0; right: 0">
<b>Program Name</b>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource2" DataTextField="Program" DataValueField="ProgramID">
</asp:DropDownList>
&nbsp &nbsp
<b>Report Period</b>
<asp:DropDownList ID="DropDownList2" runat="server" DataSourceID="SqlDataSource3" DataTextField="ReportLabel" DataValueField="DataCollectionPeriodID" Height="21px" Width="172px">
</asp:DropDownList>
<asp:Button ID="Button1" runat="server" Height="30px" OnClick="Button1_Click" Text="Search" />
</div>
You cannot transfer ListView object between pages, but you can do it with DataTable using Server.Transfer.
First Page:
DataTable dtTable;
public DataTable DataTransferTable
{
get { return dtTable; }
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
lstTransferView = new ListView();
DataView dtView = (DataView)SqlDataSource1.Select(DataSourceSelectArguments.Empty);
dtTable = new DataTable();
dtTable = dtView.ToTable().Clone();
DataRow dtRow;
foreach (ListViewDataItem lstItem in lstView.Items)
{
if (((CheckBox)lstItem.FindControl("chkBox")).Checked)
{
dtRow = (DataRow)dtView.Table.Rows[lstItem.DataItemIndex];
dtTable.ImportRow(dtRow);
}
}
Server.Transfer("~/SecondPage.aspx");
}
Second Page:
public FirstPageClass ftPage;
DataTable dtNewTable;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
ftPage= (FirstPageClass)Context.Handler;
dtNewTable = (DataTable)ftPage.DataTransferTable;
lstSecondView.DataSource = dtNewTable;
lstSecondView.DataBind();
}

How to get each row data using button field in gridview to display in textbox?

I want to display my gridview details in respective textbox by clicking Edit buttonfield appear in gridview. I am able get only first row(row[0]) data, either by default or by clicking all over the another rows. But I need each row by clicking each row edit button. Here is my design code. I am using VS 2013 and SQL Server 2012.
<%# Page Language="C#" AutoEventWireup="true" CodeBehind="Admin.aspx.cs" Inherits="RigoTest.Admin" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<style type="text/css">
.auto-style1 {
width: 50%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<center>
<asp:GridView ID="gvdetails" runat="server" AutoGenerateColumns="False" CellPadding="4" ForeColor="#333333"
GridLines="None" Width="800px" HorizontalAlign="Center" OnRowEditing="gvdetails_RowEditing" OnRowCommand="gvdetails_RowCommand">
<AlternatingRowStyle BackColor="White" ForeColor="#284775" />
<Columns>
<%--<asp:TemplateField HeaderText="ID" Visible="false">
<EditItemTemplate>
<asp:TextBox ID="txtID" runat="server" Text='<%# Bind("ID") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblID" runat="server" Text='<%# Bind("ID") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Question">
<EditItemTemplate>
<asp:TextBox ID="txtQue" runat="server" Text='<%# Bind("question") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="lblQue" runat="server" Text='<%# Bind("question") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
--%>
<asp:BoundField DataField="ID" HeaderText="ID" Visible="false" />
<asp:BoundField DataField="question" HeaderText="Question" />
<%--<asp:CommandField ShowEditButton="True" HeaderText="Edit2" />--%>
<asp:ButtonField HeaderText="Edit" CommandName="edit" Text="Edit" />
<%--<asp:CommandField CausesValidation="False" HeaderText="Edit2" InsertVisible="False" ShowCancelButton="False" ShowEditButton="True" UpdateText="" />--%>
</Columns>
<EditRowStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
<SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#E9E7E2" />
<SortedAscendingHeaderStyle BackColor="#506C8C" />
<SortedDescendingCellStyle BackColor="#FFFDF8" />
<SortedDescendingHeaderStyle BackColor="#6F8DAE" />
</asp:GridView>
</center>
</div>
<div style="height: 300px; margin-top: 250px">
<center>
<table width="40%" class="auto-style1">
<tr>
<td>
Add/Edit Question</td>
<td>
</td>
<td> </td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td> </td>
</tr>
<tr>
<td>
<asp:Label ID="Label5" runat="server" Text="Question :"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtquestion" runat="server" Width="295px"></asp:TextBox>
</td>
<td> </td>
</tr>
<tr>
<td>
<asp:Label ID="Label3" runat="server" Text="Option :"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtoption" runat="server" Width="295px"></asp:TextBox>
</td>
<td>
<asp:Button ID="btnadd" runat="server" Text="Add" Width="50px" OnClick="btnadd_Click" />
</td>
</tr>
<tr>
<td> </td>
<td>
<asp:ListBox ID="ListBox1" runat="server" Width="300px"></asp:ListBox>
</td>
<td>
<asp:Button ID="btndelete" runat="server" Text="Delete" Width="50px" OnClick="btndelete_Click" />
<br />
<br />
<asp:Button ID="btnselect" runat="server" Text="Select" Width="50px" OnClick="btnselect_Click" />
</td>
</tr>
<tr>
<td>
<asp:Label ID="Label4" runat="server" Text="Correct Option :"></asp:Label>
</td>
<td>
<asp:TextBox ID="txtcorrectoption" runat="server" Width="295px"></asp:TextBox>
</td>
<td> </td>
</tr>
<tr>
<td>
<br />
<asp:Button ID="btnsave" runat="server" Text="Save" Width="100px" />
</td>
<td> </td>
<td> </td>
</tr>
</table>
</center>
</div>
</form>
</body>
HERE IS MY ASP.NET CODE
public partial class Admin : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("server = yamma; uid = sa; pwd = /*-; database = rigo");
SqlCommand cmd;
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
public static DataTable dtDefault = new DataTable();
public Int64 n;
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack)
{
showdata();
//string EditID = Request.QueryString["EditId"];
}
}
public void showdata()
{
if (con.State == ConnectionState.Closed)
{
con.Open();
}
cmd = new SqlCommand("RigoSelect", con);
cmd.CommandType = CommandType.StoredProcedure;
da.SelectCommand = cmd;
da.Fill(dt);
da.Fill(dtDefault);
gvdetails.DataSource = dt;
gvdetails.DataBind();
}
protected void btnadd_Click(object sender, EventArgs e)
{
ListBox1.Items.Add(txtoption.Text); //to select data from textbox to listbox
}
protected void btndelete_Click(object sender, EventArgs e)
{
string remove = ListBox1.SelectedItem.Text;
ListBox1.Items.Remove(remove);
////clear all items in listbox
//listBox1.Items.Clear();
}
protected void btnselect_Click(object sender, EventArgs e)
{
txtcorrectoption.Text = ListBox1.SelectedItem.Text;
}
protected void gvdetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
//private Int64 n;
//for(int i=0;i<=n;i++)
//{
int id = int.Parse(gvdetails.Rows[0].Cells[0].Text);
DataRow[] dr = null;
dr = dtDefault.Select("ID = '" + id + "'");
txtquestion.Text = dr[0]["question"].ToString();
txtoption.Text = dr[0]["options"].ToString();
//}
showdata();
}
protected void gvdetails_RowEditing(object sender, GridViewEditEventArgs e)
{
// when boundfied is exist in gridview then id can get....thisway
//int id = int.Parse(gvdetails.Rows[e.NewEditIndex].Cells[0].Text);
////Label lbl = (Label)gvdetails.Rows[e.NewEditIndex].Cells[0].FindControl("lblID");
////string id = lbl.Text.Trim();
////int EID = int.Parse(id);
//// Response.Redirect("Admin.aspx?EditId=" + id + "");
//DataRow[] dr = null;
//dr = dtDefault.Select("ID = '" + id + "'");
//txtquestion.Text = dr[0]["question"].ToString();
//txtoption.Text = dr[0]["options"].ToString();
//showdata();
}
}
}
My problem occurs here
protected void gvdetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
//private Int64 n;
//for(int i=0;i<=n;i++)
//{
int id = int.Parse(gvdetails.Rows[0].Cells[0].Text);
DataRow[] dr = null;
dr = dtDefault.Select("ID = '" + id + "'");
txtquestion.Text = dr[0]["question"].ToString();
txtoption.Text = dr[0]["options"].ToString();
//}
showdata();
}
Here is my main problem occurs:
protected void gvdetails_RowCommand(object sender, GridViewCommandEventArgs e)
{
//private Int64 n;
//for(int i=0;i<=n;i++)
//{
int id = int.Parse(gvdetails.Rows[0].Cells[0].Text);
DataRow[] dr = null;
dr = dtDefault.Select("ID = '" + id + "'");
txtquestion.Text = dr[0]["question"].ToString();
txtoption.Text = dr[0]["options"].ToString();
//}
showdata();
}
When I click on any row that display only first row data. I want to get each row data by each clicking on respective textbox of grid row.
I have tried with commandfield but when try to add the data of option textbox (txtoption) in listbox with add button, it automatically display update, cancel option in gridview.
In the gvdetails_RowCommand event, you're always accessing the first row in the GridView.
int id = int.Parse(gvdetails.Rows[0].Cells[0].Text);
See if this works instead (referencing the currently selected row):
int id = int.Parse(gvdetails.SelectedRow.Cells[0].Text);
Here is a sample code for your reference. Hope this helps.
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName =="edit")
{
int i = Convert.ToInt32(e.CommandArgument);
YourTextBox1.Text = GridView1.Rows[i].Cells[0].Text;
YourTextBox2.Text = GridView1.Rows[i].Cells[1].Text;
}
}

Best way to show/hide a textbox when checkbox is checked/unchecked in a datalist

I'm new to aspnet programming and need some help. I've been scouring the internet and can't find a solution to my problem. I basically need a way to have a textbox show only when it's corresponding checkbox is checked. The textboxes and checkboxes are part of an inner datalist; the controls have to be databound. I've tried JQuery and couldn't get it to work, so now I'm trying AJAX with the UpdatePanel--still not working right. Below is my current code which resides in a user control. I basically included code that pertains to the checkboxes/textboxes. The script manager is referenced in the master page. Any help would be appreciated.
Thanks in advance!
HTML ----->
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DataList ID="outerDataList" runat="server" OnItemDataBound="outerRep_ItemDataBound">
<ItemTemplate>
<div id="div1" runat="server" visible='<%# ((string)Eval("Code")) != "BABRB" %>'>
<asp:Label ID="lblBABProdType" Font-Size="Medium" Font-Bold="true" runat="server" Text='<%# Eval("Name") %>' style="padding-left:20px" />
<asp:DataList ID="innerDataList" runat="server" RepeatColumns="3" DataKeyField="ProductID" >
<ItemTemplate>
<div id="div4" runat="server" visible='<%# ((string)Eval("ProductCode")) == "BABBE" %>'>
<table ID="table4" runat="server" align="left" width="80%" style="margin-left:30px; font-size:smaller">
<tr>
<td width="3%">
<asp:CheckBox ID="bevCheckBox" runat="server" AutoPostBack="true"
OnCheckedChanged="chkBox_CheckedChanged"/>
</td>
<td align="left" width="7%">
<asp:ImageButton ID="bevImgBtn" runat="server" width="40" height="40" align="middle"
ImageUrl='<%# "~/ProductImages/"+Eval("Image1FileName").ToString() %>'
OnClick="ImgBtn_Click" CommandArgument='<%# Eval("ProductID") %>'/>
</td>
<td valign="middle" width="70%">
<span class="ProductName">
<asp:LinkButton ID="bevLnkBtn" runat="server" OnClick="LnkBtn_Click" CssClass="BABProductName"
CommandArgument='<%# Eval("ProductID") %>'>
<%# DataBinder.Eval(Container.DataItem, "Name")%>
<br /></asp:LinkButton>
</span>
<span class="ProductPrice">
<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}")%>
</span
<asp:TextBox ID="bevQtyTxtBox" runat="server" Text="Qty: " Font-Size="XX-Small"
Width="40px" ViewStateMode="Disabled"/>
</td>
</tr>
</table>
</div>
<div id="div5" runat="server" visible='<%# ((string)Eval("ProductCode")) == "BABFO" %>' >
<table ID="table5" runat="server" align="left" width="80%" style="margin-left:30px; font-size:smaller">
<tr>
<td width="3%">
<asp:CheckBox ID="foodCheckBox" runat="server" AutoPostBack="true"
OnCheckedChanged="chkBox_CheckedChanged"/>
</td>
<td align="left" width="7%">
<asp:ImageButton ID="foodImgBtn" runat="server" width="40" height="40" align="middle"
ImageUrl='<%# "~/ProductImages/"+Eval("Image1FileName").ToString() %>'
OnClick="ImgBtn_Click" CommandArgument='<%# Eval("ProductID") %>'/>
</td>
<td valign="middle" width="70%">
<span class="ProductName">
<asp:LinkButton ID="foodLnkBtn" runat="server" OnClick="LnkBtn_Click" CssClass="BABProductName"
CommandArgument='<%# Eval("ProductID") %>'>
<%# DataBinder.Eval(Container.DataItem, "Name")%>
<br /></asp:LinkButton>
</span>
<span class="ProductPrice">
<%# DataBinder.Eval(Container.DataItem, "Price", "{0:c}")%>
</span>
<asp:TextBox ID="foodQtyTxtBox" runat="server" Text="Qty: " Font-Size="XX-Small"
Width="40px" ViewStateMode="Disabled"/>
</td>
</tr>
</table>
</div>
</ItemTemplate>
</asp:DataList>
</div>
<br />
</ItemTemplate>
</asp:DataList>
</ContentTemplate>
</asp:UpdatePanel>
CODE BEHIND ----->
protected void Page_Load(object sender, EventArgs e)
{
PopulateData();
}
private void PopulateData()
{
// Retrieve list of products
string categoryID = Request.QueryString["BABCategoryID"];
// set the stored procedure name
SqlConnection sqlConn = new SqlConnection(ChocolateExpConfiguration.DbConnectionString);
SqlCommand sqlComm = new SqlCommand("GetBABProductsInCategory", sqlConn);
sqlComm.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adptr = new SqlDataAdapter(sqlComm);
sqlComm.Parameters.AddWithValue("#BABCategoryID", categoryID);
DataSet ds = new DataSet();
adptr.Fill(ds);
ds.Relations.Add(new DataRelation("CodeRelation", ds.Tables[0].Columns["Code"], ds.Tables[1].Columns["ProductCode"]));
outerDataList.DataSource = ds.Tables[0];
outerDataList.DataBind();
}
protected void outerRep_ItemDataBound(object sender, DataListItemEventArgs e)
{
if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem))
{
DataRowView drv = e.Item.DataItem as DataRowView;
DataList innerDataList = (DataList)e.Item.FindControl("innerDataList");
innerDataList.DataSource = drv.CreateChildView("CodeRelation");
innerDataList.DataBind();
}
}
protected void chkBox_CheckedChanged(object sender, EventArgs e)
{
foreach (DataListItem parentItem in outerDataList.Items)
{
//Find nested items(DataList) of parent Datalist
DataList innerDataList = (DataList)parentItem.FindControl("innerDataList");
foreach (DataListItem childItem in innerDataList.Items)
{
CheckBox bevCheckBox = (CheckBox)childItem.FindControl("bevCheckBox");
CheckBox foodCheckBox = (CheckBox)childItem.FindControl("foodCheckBox");
TextBox bevQtyTxtBox = (TextBox)childItem.FindControl("bevQtyTxtBox");
TextBox foodQtyTxtBox = (TextBox)childItem.FindControl("foodQtyTxtBox");
if ((bevCheckBox.Checked == true) || (foodCheckBox.Checked == true))
{
bevQtyTxtBox.Visible = true;
foodQtyTxtBox.Visible = true;
}
else
{
bevQtyTxtBox.Visible = false;
foodQtyTxtBox.Visible = false;
}
UpdatePanel1.Update();
}
}
}*
protected void EnableTextBox()
{
int count = int.Parse(GridView1.Rows.Count.ToString());
for (int i = 0; i < count; i++)
{
CheckBox cb = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox1");
CheckBox cb1 = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox2");
CheckBox cb2 = (CheckBox)GridView1.Rows[i].Cells[0].FindControl("CheckBox3");
TextBox tb = (TextBox)GridView1.Rows[i].Cells[4].FindControl("txtration");
TextBox tb1 = (TextBox)GridView1.Rows[i].Cells[5].FindControl("txtjob");
TextBox tb2 = (TextBox)GridView1.Rows[i].Cells[6].FindControl("txtaadhar");
if (cb.Checked == true)
{
tb.Visible = true;
}
else
{
tb.Visible = false;
}
if (cb1.Checked == true)
{
tb1.Visible = true;
}
else
{
tb1.Visible = false;
}
if (cb2.Checked == true)
{
tb2.Visible = true;
}
else
{
tb2.Visible = false;
}
}
}
in checkedchanged event
protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
{
EnableTextBox();
}

Listview Cannot select last row

i have an asp.net ListView and i want when i click the select linkbutton to select the row and pass the id of the data to a detailsview. It passes the id for all records except the last one. Any reasons why?
<asp:ListView ID="ListView1" runat="server" DataKeyNames="AnswerID" OnSelectedIndexChanging="ListView1_SelectedIndexChanging">
<EmptyDataTemplate>
<table runat="server" style="">
<tr>
<td>
No data was returned.
</td>
</tr>
</table>
</EmptyDataTemplate>
<ItemTemplate>
<tr style="">
<td>
<asp:LinkButton ID="SelectButton" runat="server" CommandName="Select" Text="Select" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("AnswerID") %>'></asp:Label>
</td>
<td>
<asp:Label ID="Question" runat="server" Text='<%# Eval("QuestionText") %>' />
</td>
<td>
<asp:Label ID="UserAnswer" runat="server" Text='<%# Eval("UserAnswerTxt") %>' />
</td>
<td>
<asp:Label ID="CorrectAns" runat="server" Text='<%# Eval("CorrectAnswerTxt") %>' />
</td>
<td>
<asp:Image ID="Image1" ImageUrl='<%# Eval("ImagePath") %>' Width="48" Height="48"
runat="server" />
</td>
</tr>
</ItemTemplate>
<LayoutTemplate>
<table runat="server">
<tr runat="server">
<td runat="server">
<table id="itemPlaceholderContainer" runat="server" border="0" style="">
<tr runat="server" style="">
<th runat="server">
</th>
<th runat="server">
AnswerID
</th>
<th runat="server">
QuestionText
</th>
<th runat="server">
UserAnswerTxt
</th>
<th runat="server">
CorrectAnswerTxt
</th>
<th runat="server">
</th>
<th runat="server">
</th>
</tr>
<tr id="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr runat="server">
<td runat="server" style="">
</td>
</tr>
</table>
</LayoutTemplate>
<SelectedItemTemplate>
<tr style="">
<td>
<asp:LinkButton ID="SelectButton" runat="server" CommandName="Select" Text="Select" />
</td>
<td>
<asp:Label ID="Label1" runat="server" Text='<%# Eval("AnswerID") %>'></asp:Label>
</td>
<td>
<asp:Label ID="Question" runat="server" Text='<%# Eval("QuestionText") %>' />
</td>
<td>
<asp:Label ID="UserAnswer" runat="server" Text='<%# Eval("UserAnswerTxt") %>' />
</td>
<td>
<asp:Label ID="CorrectAns" runat="server" Text='<%# Eval("CorrectAnswerTxt") %>' />
</td>
<td>
<asp:Image ID="Image1" ImageUrl='<%# Eval("ImagePath") %>' Width="48" Height="48"
runat="server" />
</td>
</tr>
</SelectedItemTemplate>
</asp:ListView>
<asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="125px" AutoGenerateRows="False"
DataSourceID="SqlDataSource1">
<Fields>
<asp:BoundField DataField="AnswerID" HeaderText="AnswerID" SortExpression="AnswerID" />
<asp:BoundField DataField="AnswerExplanation" HeaderText="AnswerExplanation" SortExpression="AnswerExplanation" />
<asp:BoundField DataField="SuggestionText" HeaderText="SuggestionText" SortExpression="SuggestionText" />
<asp:BoundField DataField="LessonID" HeaderText="LessonID" SortExpression="LessonID" />
</Fields>
</asp:DetailsView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
SelectCommand="SELECT [ErDiagID], [AnswerID], [LessonID], [AnswerExplanation], [SuggestionText] FROM [ErrorDiagnosis] WHERE ([AnswerID] = #AnswerID)">
<SelectParameters>
<asp:ControlParameter ControlID="ListView1" Name="AnswerID" PropertyName="SelectedValue"
Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>
protected void Page_Load(object sender, EventArgs e)
{
Panel p = (Panel)Master.FindControl("Panel1");
if (p != null)
{
p.Visible = false;
}
ArrayList al = (ArrayList)Session["AnswerList"];
if (!Page.IsPostBack)
{
ListView1.DataBind();
}
if (al == null)
{
Response.Redirect("~/Default.aspx");
}
SqlConnection connection = null;
try
{
ListView1.DataSource = al;
//ListView1.SelectedIndex = ListView1.Items.Count - 1;
ListView1.DataBind();
//ListView1.SelectedIndex = ListView1.Items.Count - 1;
ListView1.SelectedIndex = -1;
if (IsPostBack == false)
{
double questions = al.Count;
double correct = 0.0;
for (int i = 0; i < al.Count; i++)
{
Answer a = (Answer)al[i];
if (a.Result == Answer.ResultValue.Correct)
{
correct++;
}
}
//foreach (ListViewItem item in resultGrid.Items)
//{
// Label cor = (Label)item.FindControl("CorrectAns");
// Label useran = (Label)item.FindControl("UserAnswer");
// if (cor.Text != useran.Text)
// {
// useran.Font.Bold = true;
// }
//}
double score = (correct / questions) * 100;
Scorelbl.Text = string.Format("{0:0.##}", score) + "%";
if (score >= 80 && score < 100)
{
resultext.Text = "Μπράβο " + Profile.UserName + "!!!";
}
connection = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
connection.Open();
SqlDataSource userQuizDataSource = new SqlDataSource();
userQuizDataSource.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString"].ToString();
userQuizDataSource.InsertCommand = "INSERT INTO [UserQuiz] ([QuizID], [DateTimeComplete], [Score], [UserName]) VALUES (#QuizID, GETDATE(), #Score, #UserName)";
userQuizDataSource.InsertParameters.Add("QuizID", Session["QuizID"].ToString());
userQuizDataSource.InsertParameters.Add("Score", score.ToString());
userQuizDataSource.InsertParameters.Add("UserName", User.Identity.Name);
int rowsAffected = userQuizDataSource.Insert();
connection.Close();
if (rowsAffected == 0)
{
errorLabel.Text = "";
}
}
}
catch (Exception exp)
{
//throw new Exception(exp.ToString(), exp);
Response.Redirect("~/Default.aspx");
}
}
protected void ListView1_SelectedIndexChanging(object sender, ListViewSelectEventArgs e)
{
ListView1.SelectedIndex = e.NewSelectedIndex;
string id = ListView1.SelectedDataKey.Value.ToString();
SqlDataSource1.SelectParameters["AnswerID"].DefaultValue = id;
ListView1.DataBind();
}
Try this to get the selected Rows value
ListView1.SelectedIndex = e.NewSelectedIndex;
string id=ListView1.SelectedDataKey.Value.ToString();
//Then pass the id's value
ListView1.DataBind();
Hope it helps.

load aspx page which is include listview in Masterpage that contain Updatepanel

actually I'm developing a template using ASP.net and C#.
as you can see below picture, my template include 3 part and i want to have partial refreshing, that's why i'm using updatepanel.
in this template once the user click at the top menu it will refresh the side menu then when the user click on the side menu it will refresh the middle content page.
i'm using masterpage in this scenario because i'm going to load aspx page at the middle content page. based on my code the normal page easily load at this part but when i want to load the page which is include listview:
<%# Page Title="" Language="C#" MasterPageFile="~/MainMasterPage.master" AutoEventWireup="true" CodeFile="ContentPage1.aspx.cs" Inherits="ContentPage1" %>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder3" Runat="Server" Visible="true">
<asp:Panel ID="ContentPanel" runat="server" Visible="true">
<fieldset style=" height:350px;">
<legend>Details</legend>
<asp:Label ID="TestLable" runat="server" Text="This is a test"></asp:Label>
<!--------- ListView Block --------->
<asp:ListView ID="lvEmployee" runat="server"
onitemediting="lvEmployee_ItemEditing"
onitemupdating="lvEmployee_ItemUpdating"
onitemcanceling="lvEmployee_ItemCanceling"
onitemdeleting="lvEmployee_ItemDeleting"
InsertItemPosition="LastItem"
OnSorting="lvEmployee_Sorting"
oniteminserting="lvEmployee_ItemInserting"
DataKeyNames="EmpID" >
<LayoutTemplate>
<!---- Layout Template: is the place to design the form layout ---->
<table id="Table1" runat="server">
<tr id="Tr1" runat="server">
<td id="Td1" runat="server">
<table ID="itemPlaceholderContainer" runat="server" border="1" style="background-color: #DCDCDC;border-collapse: collapse;border-color: #999999;border-style:none;border-width:1px;font-family: Verdana, Arial, Helvetica, sans-serif;">
<tr id="Tr2" runat="server" style="">
<th id="Th1" runat="server">
</th>
<th id="Th2" runat="server">
EmpID
<asp:ImageButton ID="imEmpID" CommandArgument="EmpID" CommandName="Sort" ImageUrl="~/img/asc.png" runat="server" />
</th>
<th id="Th3" runat="server">
EmpName
<asp:ImageButton ID="imEmpName" CommandArgument="EmpName" CommandName="Sort" ImageUrl="~/img/asc.png" runat="server" />
</th>
<th id="Th4" runat="server">
Department
</th>
<th id="Th5" runat="server">
Age
</th>
<th id="Th6" runat="server">
Address
</th>
</tr>
<tr ID="itemPlaceholder" runat="server">
</tr>
</table>
</td>
</tr>
<tr id="Tr3" runat="server">
<td id="Td2" runat="server" style="text-align: center;background-color: #CCCCCC;">
<asp:ValidationSummary ID="ValidationSummary1" runat="server" HeaderText="You received the following errors:" ShowMessageBox="true" ShowSummary="false" ValidationGroup="VGEditTmp" />
<asp:ValidationSummary ID="ValidationSummary2" runat="server" HeaderText="You received the following errors:" ShowMessageBox="true" ShowSummary="false" ValidationGroup="VGInsertTmp" />
</td>
</tr>
</table>
<br />
<asp:DataPager ID="DataPager1" runat="server" PagedControlID="lvEmployee" PageSize="5" onprerender="DataPager1_PreRender">
<Fields>
<asp:NextPreviousPagerField ButtonType="Button" ShowFirstPageButton="true" ShowLastPageButton="true"/>
<asp:TemplatePagerField>
<PagerTemplate>
<span style="color:Maroon;">Records:
<%# Container.StartRowIndex >= 0 ? (Container.StartRowIndex + 1) : 0 %>
-
<%# (Container.StartRowIndex + Container.PageSize) > Container.TotalRowCount ? Container.TotalRowCount : (Container.StartRowIndex + Container.PageSize)%>
of
<%# Container.TotalRowCount %>
<span style="color:Red;">
OR
</span>
<span style="color: Blue;">
Page
<%# Container.TotalRowCount>0 ? (Container.StartRowIndex / Container.PageSize) + 1 : 0 %>
of
<%# Math.Ceiling((double)Container.TotalRowCount / Container.PageSize) %>
</span>
</span>
</PagerTemplate>
</asp:TemplatePagerField>
</Fields>
</asp:DataPager>
</LayoutTemplate>
<ItemTemplate>
<!---- Item Template: is the place to design how to show the items inside the form ---->
<tr style="background-color:#FFF8DC;color: #000000;">
<td>
<asp:Button ID="DeleteButton" runat="server" CommandName="Delete" Text="Delete" CausesValidation="false" OnClientClick="return confirm('Are you sure you want to delete this Employee Details?');" />
<asp:Button ID="EditButton" runat="server" CommandName="Edit" Text="Edit" CausesValidation="false" />
</td>
<td>
<asp:Label ID="EmpIDLabel" runat="server" Text='<%# Eval("EmpID") %>' />
</td>
<td>
<asp:Label ID="EmpNameLabel" runat="server" Text='<%# Eval("EmpName") %>' />
</td>
<td>
<asp:Label ID="DepartmentLabel" runat="server" Text='<%# Eval("Department") %>' />
</td>
<td>
<asp:Label ID="AgeLabel" runat="server" Text='<%# Eval("Age") %>' />
</td>
<td>
<asp:Label ID="AddressLabel" runat="server" Text='<%# Eval("Address") %>' />
</td>
</tr>
</ItemTemplate>
<EditItemTemplate>
<!---- Edit Item Template: is the place to design the edit form ---->
<tr style="background-color:#008A8C;color: #FFFFFF;">
<td>
<asp:Button ID="UpdateButton" runat="server" CommandName="Update" Text="Update" ValidationGroup="VGEditTmp" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
</td>
<td>
<asp:Label ID="EmpIDLabel1" runat="server" Text='<%# Eval("EmpID") %>' />
</td>
<td>
<asp:TextBox ID="EmpNameTextBox" runat="server" Text='<%# Bind("EmpName") %>' ValidationGroup="VGEditTmp" />
<asp:RequiredFieldValidator runat="server" ID="RequiredName" ControlToValidate="EmpNameTextBox" ErrorMessage="Name is required" ValidationGroup="VGEditTmp" Display="None" ></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="EmpNameTextBox" ValidationExpression="^[a-zA-Z'.\s]{1,50}" ErrorMessage="Enter a valid Name" ValidationGroup="VGEditTmp" Display="None"></asp:RegularExpressionValidator>
</td>
<td>
<asp:TextBox ID="DepartmentTextBox" runat="server" Text='<%# Bind("Department") %>' />
</td>
<td>
<asp:TextBox ID="AgeTextBox" runat="server" Text='<%# Bind("Age") %>' ValidationGroup="VGEditTmp" />
<asp:RangeValidator ID="ValidateAge" runat="server" ControlToValidate="AgeTextBox" MinimumValue="18" MaximumValue="50" Type="Integer" ErrorMessage="Age should be within the valid interval" ValidationGroup="VGEditTmp" SetFocusOnError="true" Display="None"></asp:RangeValidator>
</td>
<td>
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
</td>
</tr>
</EditItemTemplate>
<InsertItemTemplate>
<!---- Insert Item Template: is the place to design the insert form ---->
<tr style="background-color:#008A8C;font-weight: bold;color: #FFFFFF;">
<td>
<asp:Button ID="InsertButton" runat="server" CommandName="Insert" Text="Insert" ValidationGroup="VGInsertTmp" />
<asp:Button ID="CancelButton" runat="server" CommandName="Cancel" Text="Clear" CausesValidation="false" />
</td>
<td>
</td>
<td>
<asp:TextBox ID="EmpNameTextBox" runat="server" Text='<%# Bind("EmpName") %>' ValidationGroup="VGInsertTmp" />
<asp:RequiredFieldValidator runat="server" ID="RequiredName" ControlToValidate="EmpNameTextBox" ErrorMessage="Name is required" ValidationGroup="VGInsertTmp" Display="None"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="regName" runat="server" ControlToValidate="EmpNameTextBox" ValidationExpression="^[a-zA-Z'.\s]{1,50}" ErrorMessage="Enter a valid Name" ValidationGroup="VGInsertTmp" Display="None"></asp:RegularExpressionValidator>
</td>
<td>
<asp:TextBox ID="DepartmentTextBox" runat="server" Text='<%# Bind("Department") %>' />
</td>
<td>
<asp:TextBox ID="AgeTextBox" runat="server" Text='<%# Bind("Age") %>' ValidationGroup="VGInsertTmp" />
<asp:RangeValidator ID="ValidateAge" runat="server" ControlToValidate="AgeTextBox" MinimumValue="18" MaximumValue="50" Type="Integer" ErrorMessage="Age should be within the valid interval" ValidationGroup="VGInsertTmp" SetFocusOnError="true" Display="None"></asp:RangeValidator>
</td>
<td>
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
</td>
</tr>
</InsertItemTemplate>
</asp:ListView>
<asp:HiddenField ID="hid_UpdateQT" Value="" runat="server" />
<asp:HiddenField ID="hid_SortExpression" Value="" runat="server" />
</fieldset>
</asp:Panel>
</asp:Content>
it is not showing the page. my code behind of this listview page is as below:
protected void Page_Load(object sender, EventArgs e)
{
if(IsPostBack)
{
BindLV("");
}
}
public DataTable GetEmployee(string query)
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
SqlDataAdapter ada = new SqlDataAdapter(query, con);
DataTable dtEmp = new DataTable();
ada.Fill(dtEmp);
return dtEmp;
}
private void BindLV(string SortExpression)
{
string UpdateQuery = "Select * from Employee" + SortExpression;
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
hid_UpdateQT.Value = UpdateQuery;
lvEmployee.Items.Clear();
lvEmployee.DataSource = GetEmployee(UpdateQuery);
lvEmployee.DataBind();
}
protected void lvEmployee_Sorting(object sender, ListViewSortEventArgs e)
{
ImageButton imEmpID = lvEmployee.FindControl("imEmpID") as ImageButton;
ImageButton imEmpName = lvEmployee.FindControl("imEmpName") as ImageButton;
string DefaultSortIMG = "~/img/asc.png";
string imgUrl = "~/img/desc.png";
string sortExpression = hid_SortExpression.Value;
if (!"".Equals(sortExpression))
{
if (e.SortExpression.Equals(sortExpression))
{
hid_SortExpression.Value = "";
sortExpression = "";
imgUrl = DefaultSortIMG;
}
else
{
hid_SortExpression.Value = e.SortExpression;
sortExpression = e.SortExpression;
}
}
else
{
hid_SortExpression.Value = e.SortExpression;
sortExpression = e.SortExpression;
}
switch (e.SortExpression)
{
case "EmpID":
if (imEmpName != null)
imEmpName.ImageUrl = DefaultSortIMG;
if (imEmpID != null)
imEmpID.ImageUrl = imgUrl;
break;
case "EmpName":
if (imEmpID != null)
imEmpID.ImageUrl = DefaultSortIMG;
if (imEmpName != null)
imEmpName.ImageUrl = imgUrl;
break;
}
BindLV(" order by " + e.SortExpression + " " + (!"".Equals(sortExpression) ? "ASC" : "DESC"));
}
protected void DataPager1_PreRender(object sender, EventArgs e)
{
//string strtmp = Request.Params["hid_UpdateQT"];
string strtmp = hid_UpdateQT.Value;
if (null == strtmp || "".Equals(strtmp))
{
strtmp = "Select * from Employee";
}
lvEmployee.DataSource = GetEmployee(strtmp);
lvEmployee.DataBind();
}
protected void lvEmployee_ItemEditing(object sender, ListViewEditEventArgs e)
{
lvEmployee.EditIndex = e.NewEditIndex;
}
protected void lvEmployee_ItemUpdating(object sender, ListViewUpdateEventArgs e)
{
string empid = "", name = "", dept = "", age = "", address = "";
Label lbl = (lvEmployee.Items[e.ItemIndex].FindControl("EmpIDLabel1")) as Label;
if (lbl != null)
empid = lbl.Text;
TextBox txt = (lvEmployee.Items[e.ItemIndex].FindControl("EmpNameTextBox")) as TextBox;
if (txt != null)
name = txt.Text;
txt = (lvEmployee.Items[e.ItemIndex].FindControl("DepartmentTextBox")) as TextBox;
if (txt != null)
dept = txt.Text;
txt = (lvEmployee.Items[e.ItemIndex].FindControl("AgeTextBox")) as TextBox;
if (txt != null)
age = txt.Text;
txt = (lvEmployee.Items[e.ItemIndex].FindControl("AddressTextBox")) as TextBox;
if (txt != null)
address = txt.Text;
string UpdateQuery = "UPDATE [Employee] SET [EmpName] = '" + name + "', [Department] = '" + dept + "', [Age] = '" + age + "', [Address] = '" + address + "' WHERE [EmpID] = '" + empid + "'";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
con.Open();
SqlCommand com = new SqlCommand(UpdateQuery, con);
com.ExecuteNonQuery();
con.Close();
lvEmployee.DataSource = GetEmployee("Select * from Employee");
lvEmployee.DataBind();
lvEmployee.EditIndex = -1;
}
protected void lvEmployee_ItemCanceling(object sender, ListViewCancelEventArgs e)
{
lvEmployee.EditIndex = -1;
}
protected void lvEmployee_ItemDeleting(object sender, ListViewDeleteEventArgs e)
{
string empid = "";
Label lbl = (lvEmployee.Items[e.ItemIndex].FindControl("EmpIDLabel")) as Label;
if (lbl != null)
empid = lbl.Text;
string DeleteQuery = "Delete from Employee WHERE [EmpID] = '" + empid + "'";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
con.Open();
SqlCommand com = new SqlCommand(DeleteQuery, con);
com.ExecuteNonQuery();
con.Close();
lvEmployee.DataSource = GetEmployee("Select * from Employee");
lvEmployee.DataBind();
lvEmployee.EditIndex = -1;
}
protected void lvEmployee_ItemInserting(object sender, ListViewInsertEventArgs e)
{
string name = "", dept = "", age = "", address = "";
TextBox txt = (e.Item.FindControl("EmpNameTextBox")) as TextBox;
if (txt != null)
name = txt.Text;
txt = (e.Item.FindControl("DepartmentTextBox")) as TextBox;
if (txt != null)
dept = txt.Text;
txt = (e.Item.FindControl("AgeTextBox")) as TextBox;
if (txt != null)
age = txt.Text;
txt = (e.Item.FindControl("AddressTextBox")) as TextBox;
if (txt != null)
address = txt.Text;
string INSERTQuery = "INSERT INTO [Employee] (EmpName,Department,Age,Address) VALUES ('" + name + "','" + dept + "','" + age + "','" + address + "')";
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].ConnectionString);
con.Open();
SqlCommand com = new SqlCommand(INSERTQuery, con);
com.ExecuteNonQuery();
con.Close();
lvEmployee.DataSource = GetEmployee("Select * from Employee");
lvEmployee.DataBind();
lvEmployee.EditIndex = -1;
}
and my masterpage code to load this page is as below:
<asp:UpdatePanel ID="UpdatePanel3" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<!-- Initial the Page which is going to show the details of the sub-menu -->
<asp:ContentPlaceHolder id="ContentPlaceHolder3" runat="server" Visible="false">
</asp:ContentPlaceHolder>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button3" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button4" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LinkButton1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LinkButton2" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LinkButton3" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LinkButton4" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LinkButton5" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LinkButton6" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LinkButton7" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LinkButton8" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="LinkButton9" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
because i want to have partial refreshing at first i set the Visible of the ContentPlaceHolder3 to false and once the user click on the related link i just set it as true by code behind.
could you pleas guide me how to load this kind of aspx page at the masterpage.
appreciate your consideration.
i have solved this problem using User Control method.
now i have put content of the page inside uc1 and used the below code to call the page at the update panel:
<uc1:WebUserControl ID="WebUserControl1" runat="server" Visible="false" />
once the user click on the related button i just change the Visible option to True.
i hope it would be helpful.

Categories