Hi,
My requirement is, if i click on Manage button of gridview then it should show all the data in the textbox from database.
I have problem, It is working fine If contactusID visible="true" and when it is false then if i select row on gridview first time,its fine and if i select any row second time, i am getting error. There is no row at position 4 and my counter starts with 0, and i have 4 rows in my grid.
Code:-
protected void gvAppContactUs_SelectedIndexChanged(object sender, EventArgs e)
{
mvDefault.SetActiveView(vModifyApp);
VModifyContactUsInView();
hfIsNewContact.Value = false.ToString();
NewContact(false);
StyleUtility.EnableButton(btnDelete);
}
protected void VModifyContactUsInView()
{
lblApplicationName.Text = hfSysName.Value;
tcContactUs.ActiveTabIndex = 0;
LinkApplicationSearch.Visible = true;
LtrManageApplicationContactUs.Visible = false;
LtrManageApplicationRoles.Visible = false;
LtrRoleDetails.Visible = false;
LtrSeparator0.Visible = false;
LtrSeparator1.Visible = true;
LtrSeparator2.Visible = true;
LinkManageApplicationContactUs.Visible = true;
LinkManageApplicationContactUs.Text = gvApplications.SelectedDataKey["DisplayName"].ToString();
LtrContactUsDetails.Visible = true;
LtrContactUsDetails.Text = lblApplicationName.Text;
ltrContactUsDetailsContactUsName.Visible = true;
ltrContactUsDetailsContactUsName.Text = lblApplicationName.Text;
btnContactUsDelete.Enabled = false;
mvDefault.SetActiveView(vModifyContactUs);
ApplicationContactUsDal dalContact = new ApplicationContactUsDal();
DataTable dtContact = dalContact.GetAllContactUsInfo(hfSysName.Value);
String selectedContactUsID = gvAppContactUs.SelectedRow.Cells[0].Text;
int selectedRowId;
for (selectedRowId = 0; selectedRowId
if ((dtContact.Rows[selectedRowId]["ContactUsID"].ToString()).Equals(selectedContactUsID))
{
Session["contactUsID"] = selectedContactUsID;
break;
}
}
hfContactUsID.Value = selectedContactUsID;
hfApplicationName.Value = dtContact.Rows[selectedRowId]["ApplicationName"].ToString();
txtOpenDaysOfWeek.Text = dtContact.Rows[selectedRowId]["OpenDaysOfWeek"].ToString();
txtTimings.Text = dtContact.Rows[selectedRowId]["Timings"].ToString();
txtTimeZone.Text = dtContact.Rows[selectedRowId]["TimeZone"].ToString();
txtPhoneNumber.Text = dtContact.Rows[selectedRowId]["PhoneNumber"].ToString();
txtPhoneNumber2.Text = dtContact.Rows[selectedRowId]["PhoneNumber2"].ToString();
txtPhoneExtension.Text = dtContact.Rows[selectedRowId]["PhoneExtension"].ToString();
txtEmailAddress.Text = dtContact.Rows[selectedRowId]["EmailAddress"].ToString();
LinkManageApplicationContactUs.Text = gvAppContactUs.SelectedDataKey["ApplicationName"].ToString();
tcPanelContactUsDetails.Visible = true;
btnContactUsDelete.Enabled = false;
gvAppContactUs.SelectedIndex = -1;
lblApplicationName.Visible = true;
BindAppContactUsGV();
BindRoleWorkflow();
SetBreadCrumbs();
}
protected void BindAppContactUsGV()
{
// Get a list of Application ContactUs information
List
// Sort Selected Roles
switch (this.gvAppContactUs_sortOrder)
{
case "ContactUsID":
appContactUsInfo = appContactUsInfo.OrderBy(item => item.ContactUsID).ToList();
break;
case "ApplicationName":
appContactUsInfo = appContactUsInfo.OrderBy(item => item.ApplicationName).ToList();
break;
case "OpenDaysOfWeek":
appContactUsInfo = appContactUsInfo.OrderBy(item => item.OpenDaysOfWeek).ToList();
break;
case "Timings":
appContactUsInfo = appContactUsInfo.OrderBy(item => item.Timings).ToList();
break;
case "TimeZone":
appContactUsInfo = appContactUsInfo.OrderBy(item => item.TimeZone).ToList();
break;
case "PhoneNumber2":
appContactUsInfo = appContactUsInfo.OrderBy(item => item.PhoneNumber2).ToList();
break;
case "PhoneNumber":
appContactUsInfo = appContactUsInfo.OrderBy(item => item.PhoneNumber).ToList();
break;
case "PhoneExtension":
appContactUsInfo = appContactUsInfo.OrderBy(item => item.PhoneExtension).ToList();
break;
case "EmailAddress":
appContactUsInfo = appContactUsInfo.OrderBy(item => item.EmailAddress).ToList();
break;
}
if (this.gvAppContactUs_sortReverse)
{
appContactUsInfo.Reverse();
}
gvAppContactUs.DataSource = appContactUsInfo.ToArray();
gvAppContactUs.DataBind();
// String selectedContactUsID = gvAppContactUs.SelectedRow.Cells[0].Text;
gvAppContactUs.Columns[0].Visible = false;
//tpAppContactUsInfo.TabIndex = 7;
//Tabs.ActiveTab = vModifyApp.Controls[7];
//Tabs.ActiveTabIndex = 7;
//FreezeForContactUs(true);
}
aspx code: -
CellPadding="4" CssClass="gridView" DataKeyNames="ApplicationName"
EmptyDataText="There are no Contact information to display." ForeColor="#333333"
GridLines="None" OnPageIndexChanging="gvAppContactUs_PageIndexChanging"
OnSelectedIndexChanged="gvAppContactUs_SelectedIndexChanged"
OnSorting="gvAppContactUs_Sorting" PageSize="15" Width="100%">
Width="100px" />
Ajay GautamPosted Sep 18, 2010, 6:15 PM
Ajay GautamPosted Sep 7, 2010, 2:04 PM