Gridview, Add, Update, Delete and view option gridview on first gridview column click

<%——————– ASPX Page Coding ————————————–%>
<table width=”100%”>
<tr>
<td align=”center”>

Gridview, Add, Update, Delete and view option gridview on first gridview column click

Goto Page

‘>


runat=”server”>

‘>

‘>

‘>

‘ />  

CommandName=”Delete” />

 

</td>
</tr>
<tr>
<td>

</td>
</tr>
<tr>
<td align=”left”>

Question:

Goto Page

‘ Width=”150px”>

‘>

‘ Width=”150px”>

‘ Width=”150px”>

‘>

‘ Width=”150px”>

‘ />  

CommandName=”Delete” />

 

</td>
</tr>
</table>
<asp:HiddenField ID=”hfInspectionQuestionID” runat=”server” Value=”” />
<%———————————— CS Page Coding—————————————————-%>
LinqDataContext sidb = new LinqDataContext();
DataTable dt = new DataTable();
List<int> lstPriority = new List<int>();
List<clsAnswerType> lstAnswerType = new List<clsAnswerType>();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{ BindGrid(); }
else
lblQuestionMappingMsg.Text = “”;

}

private List<int> BindPriorityList()
{
lstPriority = new List<int>();
try
{
for (int i = 1; i <= 100; i++)
{
lstPriority.Add(i);
}
}
catch (Exception ex)
{
// throw;
}
return lstPriority;
}

private List<clsAnswerType> GetAnswerTypeList()
{
lstAnswerType = new List<clsAnswerType>();
try
{
lstAnswerType.Add(new clsAnswerType { AnswerType = “Single Line Descriptive”, AnswerValue = “SingleLineDescriptive” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “Multi Line Descriptive”, AnswerValue = “MultiLineDescriptive” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “Yes / No”, AnswerValue = “YesNo” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “Tabular”, AnswerValue = “Tabular” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “GoodAverageBest”, AnswerValue = “GoodAverageBest” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “Heading”, AnswerValue = “Heading” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “Date”, AnswerValue = “Date” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “FromDB”, AnswerValue = “FromDB” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “DivisionName”, AnswerValue = “DivisionName” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “BlockName”, AnswerValue = “BlockName” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “DistrictName”, AnswerValue = “DistrictName” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “ClusterName”, AnswerValue = “ClusterName” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “VillageName”, AnswerValue = “VillageName” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “InspectorName”, AnswerValue = “InspectorName” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “InspectorDesignation”, AnswerValue = “InspectorDesignation” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “InspectorDate”, AnswerValue = “InspectorDate” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “Scale10”, AnswerValue = “Scale10” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “DaysCount”, AnswerValue = “DaysCount” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “MultiRadioList”, AnswerValue = “MultiRadioList” });
lstAnswerType.Add(new clsAnswerType { AnswerType = “SchoolName”, AnswerValue = “SchoolName” });
}
catch (Exception ex)
{
// throw;
}
return lstAnswerType;
}

#region grdInspectionMap Grid
GridViewRow AddNewGridRow;
private void BindGrid()
{
try
{
var InspectionQuestionData = sidb.InspectionQuestionMasters.OrderBy(_ => _.Priority).Select(_ => new clsInspectionQuestionData { InspectionQuestionId = _.InspectionQuestionId, InspectionQuestion = _.InspectionQuestion, Priority = _.Priority, Status = _.Status, AnswerType = _.AnswerType, OptionCount = _.InspectionQuestionOptionMasters.Count() }).ToList();
if (InspectionQuestionData.Any())
{
grdInspectionMap.DataSource = InspectionQuestionData;
grdInspectionMap.DataBind();
}
else
{
dt = new DataTable();
dt.Columns.Add(“InspectionQuestionId”);
dt.Columns.Add(“InspectionQuestion”, typeof(String));
dt.Columns.Add(“Priority”, typeof(String));
dt.Columns.Add(“Status”, typeof(String));
dt.Columns.Add(“AnswerType”, typeof(String));
dt.Columns.Add(“OptionCount”, typeof(String));
dt.Rows.Add(dt.NewRow());
dt.Rows[0][0] = “false”;
dt.Rows[0][3] = “NO RESULT FOUND!”;
grdInspectionMap.DataSource = dt;
grdInspectionMap.DataBind();
}
}
catch (Exception ex)
{
(new MailClass()).SendErrorMail(ex, “ADMIN_InstectionFormMapping::BindGrid”);
}
}

protected void grdInspectionMap_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
string _Priority = Convert.ToString(grdInspectionMap.DataKeys[e.Row.RowIndex].Values[“Priority”]);
string _AnswerType = Convert.ToString(grdInspectionMap.DataKeys[e.Row.RowIndex].Values[“AnswerType”]);
int __Priority = 0;
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
// Bind ddlPriority
DropDownList ddlPriority = (DropDownList)e.Row.FindControl(“ddlPriority”);
ddlPriority.DataSource = BindPriorityList();
ddlPriority.DataBind();
if (int.TryParse(_Priority, out __Priority))
ddlPriority.SelectedValue = Convert.ToString(__Priority);

// Bind ddlAnswerType
DropDownList ddlAnswerType = (DropDownList)e.Row.FindControl(“ddlAnswerType”);
ddlAnswerType.DataSource = GetAnswerTypeList();
ddlAnswerType.DataTextField = “AnswerType”;
ddlAnswerType.DataValueField = “AnswerValue”;
ddlAnswerType.DataBind();
if (!string.IsNullOrEmpty(_AnswerType))
ddlAnswerType.SelectedValue = Convert.ToString(_AnswerType);

}
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
DropDownList ddlPriority = (DropDownList)e.Row.FindControl(“ddlPriority”);
ddlPriority.DataSource = BindPriorityList();
ddlPriority.DataBind();

// Bind ddlAnswerType
DropDownList ddlAnswerType = (DropDownList)e.Row.FindControl(“ddlAnswerType”);
ddlAnswerType.DataSource = GetAnswerTypeList();
ddlAnswerType.DataTextField = “AnswerType”;
ddlAnswerType.DataValueField = “AnswerValue”;
ddlAnswerType.DataBind();
}
}

protected void grdInspectionMap_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdInspectionMap.EditIndex = -1;
grdInspectionMap.PageIndex = e.NewPageIndex;
BindGrid();
}

protected void grdInspectionMap_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
SetPagerButtonStates(grdInspectionMap, e.Row, this, “ddlInspectionPageSelector”);
}
else if (e.Row.RowType == DataControlRowType.DataRow)
{
int InspectionQuestionId = 0;
if (int.TryParse(Convert.ToString(grdInspectionMap.DataKeys[e.Row.RowIndex].Values[“InspectionQuestionId”]), out InspectionQuestionId))
{
string AnswerType = Convert.ToString(grdInspectionMap.DataKeys[e.Row.RowIndex].Values[“AnswerType”]);
int OptionCount = Convert.ToInt32(grdInspectionMap.DataKeys[e.Row.RowIndex].Values[“OptionCount”].ToString());
LinkButton lnkbtnOption = (LinkButton)e.Row.FindControl(“lnkbtnOption”);
if (lnkbtnOption != null)
{
if (OptionCount > 0 && AnswerType == “Tabular”)
lnkbtnOption.Text = “Update Option”;
else if (AnswerType == “Tabular”)
lnkbtnOption.Text = “Add Option”;
else
lnkbtnOption.Text = “”;
lnkbtnOption.Command += new CommandEventHandler(lnkbtnOption_Click);
lnkbtnOption.CommandArgument = InspectionQuestionId.ToString();
lnkbtnOption.CommandName = “AddNewOption”;
lnkbtnOption.Attributes.Add(“style”, “text-decoration: none;”);
}
}
else
{
LinkButton lnkbtnOption = (LinkButton)e.Row.FindControl(“lnkbtnOption”);
if (lnkbtnOption != null)
lnkbtnOption.Text = “”;
}
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
AddNewGridRow = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
TableCell th = new TableHeaderCell();
th.ColumnSpan = e.Row.Cells.Count;
if (grdInspectionMap.EditIndex == -1)
{
th.HorizontalAlign = HorizontalAlign.Right;
LinkButton btnAddNew = new LinkButton();
btnAddNew.Text = “Add New”;
btnAddNew.ForeColor = System.Drawing.Color.Red;
btnAddNew.Command += new CommandEventHandler(btnAddFeedback_Click);
btnAddNew.CommandName = “AddNew”;
th.Controls.Add(btnAddNew);
}
AddNewGridRow.Cells.Add(th);
grdInspectionMap.Controls[0].Controls.Add(AddNewGridRow);
e.Row.BackColor = grdInspectionMap.FooterStyle.BackColor;
e.Row.Font.Bold = true;
}

}

protected void lnkbtnOption_Click(object sender, CommandEventArgs e)
{
if (e.CommandName == “AddNewOption”)
{
divQuestionOptionsMapping.Visible = true;
hfInspectionQuestionID.Value = e.CommandArgument.ToString();
BindgrdQuestionOptionsMapping();
}
}

protected void ddlInspectionPageSelector_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddlPageSelector = (DropDownList)grdInspectionMap.TopPagerRow.FindControl(“ddlInspectionPageSelector”);
grdInspectionMap.PageIndex = ddlPageSelector.SelectedIndex;
BindGrid();
}

protected void grdInspectionMap_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
GridViewRow row = (GridViewRow)grdInspectionMap.Rows[e.RowIndex];
int RowID = Convert.ToInt32(grdInspectionMap.DataKeys[e.RowIndex].Values[“InspectionQuestionId”].ToString());
var DeleteInspectionOption = sidb.InspectionQuestionOptionMasters.Where(_ => _.InspectionQuestionId.Equals(RowID)).ToList();
if (DeleteInspectionOption.Any())
{
sidb.InspectionQuestionOptionMasters.DeleteAllOnSubmit(DeleteInspectionOption);
sidb.SubmitChanges();
}
var DeleteInspectionQuestion = sidb.InspectionQuestionMasters.Where(_ => _.InspectionQuestionId.Equals(RowID)).ToList();
if (DeleteInspectionQuestion.Any())
{
sidb.InspectionQuestionMasters.DeleteAllOnSubmit(DeleteInspectionQuestion);
sidb.SubmitChanges();
}
grdInspectionMap.EditIndex = -1;
BindGrid();
divQuestionOptionsMapping.Visible = false;
}
catch (Exception ex)
{
(new MailClass()).SendErrorMail(ex, “ADMIN_InstectionFormMapping::grdInspectionMap_RowDeleting”);
}
}

protected void grdInspectionMap_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int InspectionQuestionId = Convert.ToInt32(grdInspectionMap.DataKeys[e.RowIndex].Values[“InspectionQuestionId”].ToString());
string txtInspectionQuestion = ((TextBox)grdInspectionMap.Rows[e.RowIndex].FindControl(“txtInspectionQuestion”)).Text.Trim();
string Priority = ((DropDownList)grdInspectionMap.Rows[e.RowIndex].FindControl(“ddlPriority”)).Text.Trim();
string AnswerType = ((DropDownList)grdInspectionMap.Rows[e.RowIndex].FindControl(“ddlAnswerType”)).SelectedItem.Value;
bool ActiveStatus = false;
string Status = ((DropDownList)grdInspectionMap.Rows[e.RowIndex].FindControl(“ddlStatus”)).SelectedValue;
if (Status == “1”)
ActiveStatus = true;

var EditableInspectionQuestion = sidb.InspectionQuestionMasters.Where(_ => _.InspectionQuestionId.Equals(InspectionQuestionId)).SingleOrDefault();
if (EditableInspectionQuestion != null)
{
EditableInspectionQuestion.InspectionQuestion = txtInspectionQuestion;
EditableInspectionQuestion.Priority = int.Parse(Priority == “” ? “0” : Priority);
EditableInspectionQuestion.AnswerType = AnswerType;
EditableInspectionQuestion.Status = ActiveStatus;
sidb.SubmitChanges();
}

grdInspectionMap.EditIndex = -1;
BindGrid();
divQuestionOptionsMapping.Visible = false;
}
protected void grdInspectionMap_RowEditing(object sender, GridViewEditEventArgs e)
{
grdInspectionMap.EditIndex = e.NewEditIndex;
BindGrid();
}
protected void grdInspectionMap_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
grdInspectionMap.EditIndex = -1;
BindGrid();
}

protected void btnAddFeedback_Click(object sender, CommandEventArgs e)
{
if (e.CommandName == “AddNew”)
{
BindGrid();
grdInspectionMap.FooterRow.Visible = true;
AddNewGridRow.Visible = false;
}
else if (e.CommandName == “Save”)
{
InsertNewFeedBackMapping((TableRow)grdInspectionMap.FooterRow);
}
}

private void InsertNewFeedBackMapping(TableRow htmlTableRow)
{

string txtInspectionQuestion = ((TextBox)htmlTableRow.FindControl(“txtInspectionQuestion”)).Text.Trim();
string Priority = ((DropDownList)htmlTableRow.FindControl(“ddlPriority”)).SelectedValue;
string AnswerType = ((DropDownList)htmlTableRow.FindControl(“ddlAnswerType”)).SelectedValue;
bool ActiveStatus = false;
string Status = ((DropDownList)htmlTableRow.FindControl(“ddlStatus”)).SelectedValue;
if (Status == “1”)
ActiveStatus = true;

InspectionQuestionMaster obj = new InspectionQuestionMaster();
obj.InspectionQuestion = txtInspectionQuestion;
obj.Priority = int.Parse(Priority);
obj.AnswerType = AnswerType;
obj.Status = ActiveStatus;
sidb.InspectionQuestionMasters.InsertOnSubmit(obj);
sidb.SubmitChanges();
grdInspectionMap.EditIndex = -1;
BindGrid();
}

#endregion

#region Bind Question Answer
GridViewRow AddNewQuestionOptionsMappingRow;
private void BindgrdQuestionOptionsMapping()
{
int InspectionQuestionId = 0;
grdQuestionOptionsMapping.Visible = false;
divQuestionOptionsMapping.Visible = true;
if (!string.IsNullOrEmpty(hfInspectionQuestionID.Value))
{
InspectionQuestionId = int.Parse(hfInspectionQuestionID.Value);
var FeedbackQueestion = sidb.InspectionQuestionMasters.Where(_ => _.InspectionQuestionId.Equals(InspectionQuestionId)).ToList();
if (FeedbackQueestion.Any())
{
lblQuestion.Text = FeedbackQueestion.First().InspectionQuestion;
}
}
else
return;

try
{
grdQuestionOptionsMapping.Visible = true;

var InspectionTabularOption = sidb.InspectionQuestionOptionMasters.Where(_ => _.InspectionQuestionId.Equals(InspectionQuestionId)).ToList();
if (InspectionTabularOption.Any())
{
grdQuestionOptionsMapping.DataSource = InspectionTabularOption;
grdQuestionOptionsMapping.DataBind();
}
else
{
DataTable dt1 = new DataTable();
dt1.Columns.Add(“InspectionQuestionOptionId”, typeof(String));
dt1.Columns.Add(“InspectionQuestionId”, typeof(String));
dt1.Columns.Add(“Row”, typeof(String));
dt1.Columns.Add(“Col”, typeof(String));
dt1.Rows.Add(dt1.NewRow());
dt1.Rows[0][0] = “false”;
dt1.Rows[0][1] = “NO RESULT FOUND!”;
grdQuestionOptionsMapping.DataSource = dt1;
grdQuestionOptionsMapping.DataBind();
}
}
catch (Exception ex)
{
(new MailClass()).SendErrorMail(ex, “ADMIN_InstectionFormMapping::BindgrdQuestionOptionsMapping”);
}
}
protected void grdQuestionOptionsMapping_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
grdQuestionOptionsMapping.EditIndex = -1;
grdQuestionOptionsMapping.PageIndex = e.NewPageIndex;
BindgrdQuestionOptionsMapping();
}
protected void grdQuestionOptionsMapping_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Pager)
{
SetPagerButtonStates(grdQuestionOptionsMapping, e.Row, this, “ddlQuestionOptionsMappingPageSelector”);
}
else if (e.Row.RowType == DataControlRowType.Footer)
{
AddNewQuestionOptionsMappingRow = new GridViewRow(0, -1, DataControlRowType.Header, DataControlRowState.Normal);
TableCell th = new TableHeaderCell();
th.ColumnSpan = e.Row.Cells.Count;
if (grdQuestionOptionsMapping.EditIndex == -1)
{
th.HorizontalAlign = HorizontalAlign.Right;
LinkButton btnAddNew = new LinkButton();
btnAddNew.Text = “Add New”;
btnAddNew.ForeColor = System.Drawing.Color.Red;
btnAddNew.Command += new CommandEventHandler(btnAddNewTemplateITKMapping_Click);
btnAddNew.CommandName = “AddNew”;
th.Controls.Add(btnAddNew);
}
AddNewQuestionOptionsMappingRow.Cells.Add(th);
grdQuestionOptionsMapping.Controls[0].Controls.Add(AddNewQuestionOptionsMappingRow);
e.Row.BackColor = grdQuestionOptionsMapping.FooterStyle.BackColor;
e.Row.Font.Bold = true;
}

}
protected void ddlQuestionOptionsMappingPageSelector_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddlPageSelector = (DropDownList)grdQuestionOptionsMapping.TopPagerRow.FindControl(“ddlQuestionOptionsMappingPageSelector”);
grdQuestionOptionsMapping.PageIndex = ddlPageSelector.SelectedIndex;
BindgrdQuestionOptionsMapping();
}
protected void grdQuestionOptionsMapping_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
try
{
int InspectionQuestionId = Convert.ToInt32(grdQuestionOptionsMapping.DataKeys[e.RowIndex].Values[“InspectionQuestionId”].ToString());
int InspectionQuestionOptionId = Convert.ToInt32(grdQuestionOptionsMapping.DataKeys[e.RowIndex].Values[“InspectionQuestionOptionId”].ToString());

var DeleteOption = sidb.InspectionQuestionOptionMasters.Where(_ => _.InspectionQuestionId.Equals(InspectionQuestionId) && _.InspectionQuestionOptionId.Equals(InspectionQuestionOptionId)).ToList();
if (DeleteOption.Any())
{
sidb.InspectionQuestionOptionMasters.DeleteAllOnSubmit(DeleteOption);
sidb.SubmitChanges();
}

// lblQuestionMappingMsg.Text = “Option Deleted Successfully”;
grdQuestionOptionsMapping.EditIndex = -1;
BindgrdQuestionOptionsMapping();
}
catch (Exception ex)
{
(new MailClass()).SendErrorMail(ex, “ADMIN_InstectionFormMapping::grdQuestionOptionsMapping_RowDeleting”);
}
}

protected void grdQuestionOptionsMapping_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
int InspectionQuestionId = Convert.ToInt32(grdQuestionOptionsMapping.DataKeys[e.RowIndex].Values[“InspectionQuestionId”].ToString());
int InspectionQuestionOptionId = Convert.ToInt32(grdQuestionOptionsMapping.DataKeys[e.RowIndex].Values[“InspectionQuestionOptionId”].ToString());
string txtQuistionRow = ((TextBox)grdQuestionOptionsMapping.Rows[e.RowIndex].FindControl(“txtQuistionRow”)).Text.Trim();
string txtQuistionCol = ((TextBox)grdQuestionOptionsMapping.Rows[e.RowIndex].FindControl(“txtQuistionCol”)).Text.Trim();

if (!sidb.InspectionQuestionOptionMasters.Where(_ => _.InspectionQuestionId.Equals(InspectionQuestionId) && _.InspectionQuestionOptionId.Equals(InspectionQuestionOptionId) && _.Row.Equals(txtQuistionRow) && _.Col.Equals(txtQuistionCol)).Any())
{
var lstInspectionOptionUpdates = sidb.InspectionQuestionOptionMasters.Where(_ => _.InspectionQuestionId.Equals(InspectionQuestionId) && _.InspectionQuestionOptionId.Equals(InspectionQuestionOptionId)).ToList();
lstInspectionOptionUpdates.First().Row = txtQuistionRow;
lstInspectionOptionUpdates.First().Col = txtQuistionCol;
sidb.SubmitChanges();
}
grdQuestionOptionsMapping.EditIndex = -1;
BindgrdQuestionOptionsMapping();
}
protected void grdQuestionOptionsMapping_RowEditing(object sender, GridViewEditEventArgs e)
{
grdQuestionOptionsMapping.EditIndex = e.NewEditIndex;
BindgrdQuestionOptionsMapping();
}
protected void grdQuestionOptionsMapping_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
grdQuestionOptionsMapping.EditIndex = -1;
BindgrdQuestionOptionsMapping();
}

protected void btnAddNewTemplateITKMapping_Click(object sender, CommandEventArgs e)
{
if (e.CommandName == “AddNew”)
{
BindgrdQuestionOptionsMapping();
grdQuestionOptionsMapping.FooterRow.Visible = true;
AddNewQuestionOptionsMappingRow.Visible = false;
}
else if (e.CommandName == “Save”)
{
InsertNewTemplateDepITKMap((TableRow)grdQuestionOptionsMapping.FooterRow);
}
}

private void InsertNewTemplateDepITKMap(TableRow htmlTableRow)
{
int InspectionQuestionId = 0;
if (!string.IsNullOrEmpty(hfInspectionQuestionID.Value))
{
InspectionQuestionId = int.Parse(hfInspectionQuestionID.Value);
string txtQuistionRow = ((TextBox)htmlTableRow.FindControl(“txtQuistionRow”)).Text.Trim();
string txtQuistionCol = ((TextBox)htmlTableRow.FindControl(“txtQuistionCol”)).Text.Trim();

InspectionQuestionOptionMaster obj = new InspectionQuestionOptionMaster();
obj.InspectionQuestionId = InspectionQuestionId;
obj.Row = txtQuistionRow;
obj.Col = txtQuistionCol;
sidb.InspectionQuestionOptionMasters.InsertOnSubmit(obj);
sidb.SubmitChanges();
// lblQuestionMappingMsg.Text = “Option added successfully”;
BindGrid();

}
else
return;
grdQuestionOptionsMapping.EditIndex = -1;
BindgrdQuestionOptionsMapping();
}
#endregion
private void SetPagerButtonStates(GridView gridView, GridViewRow gvPagerRow, Page page, String DropDownName)
{
int pageIndex = gridView.PageIndex;
int pageCount = gridView.PageCount;
Button btnFirst = (Button)gvPagerRow.FindControl(“btnFirst”);
Button btnPrevious = (Button)gvPagerRow.FindControl(“btnPrevious”);
Button btnNext = (Button)gvPagerRow.FindControl(“btnNext”);
Button btnLast = (Button)gvPagerRow.FindControl(“btnLast”);
btnFirst.Enabled = btnPrevious.Enabled = (pageIndex != 0);
btnNext.Enabled = btnLast.Enabled = (pageIndex < (pageCount – 1));
DropDownList ddlPageSelector = (DropDownList)gvPagerRow.FindControl(DropDownName);
ddlPageSelector.Items.Clear();
for (int i = 1; i <= gridView.PageCount; i++)
{
ddlPageSelector.Items.Add(i.ToString());
}
ddlPageSelector.SelectedIndex = pageIndex;
}

class clsInspectionQuestionData
{
public int InspectionQuestionId { get; set; }
public string InspectionQuestion { get; set; }
public int? Priority { get; set; }
public bool? Status { get; set; }
public string AnswerType { get; set; }
public int OptionCount { get; set; }
}

class clsAnswerType
{
public string AnswerType { get; set; }
public string AnswerValue { get; set; }
}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s