To solve an exception details in web site creation - c#

I am creating a web site but anytime I run this code, an exception is raised:
#Exception Details: System.IndexOutOfRangeException: There is no row at position 0.
How do I solve this problem?
public partial class Employee_frmSearchClaims : System.Web.UI.Page
{
int empno;
protected void Page_Load(object sender, EventArgs e)
{
if (Session["empno"] != null)
empno = int.Parse(Session["empno"].ToString());
if (!IsPostBack)
{
DataRow r = AddPoliciesOnEmployees.GetPolicyOnEmployee(empno).Tables[0].Rows[0];
Label7.Text = r["policyname"].ToString();
Label8.Text = r["policyid"].ToString();
Label9.Text = r["policyamount"].ToString();
Label10.Text = r["TotalAmount"].ToString();
Label11.Text = r["pstartdate"].ToString();
}
}
protected void btnapplicy_Click(object sender, EventArgs e)
{
if (ddlReason.SelectedItem.ToString() != "--Select--")
{
if (ddlReason.SelectedItem.Text == "Death")
{
Session["Reason"] = ddlReason.SelectedItem.Text;
Response.Redirect("frmDeathCliam.aspx");
}
else if (ddlReason.SelectedItem.Text == "Accident")
{
Session["Reason"] = ddlReason.SelectedItem.Text;
Response.Redirect("frmAccidentClaim.aspx");
}
else
{
Session["Reason"] = ddlReason.SelectedItem.Text;
Response.Redirect("frmCompleteClaim.aspx");
}
}
else
lblmsg.Text = "You have to select the reason";
}
}

You need to make sure your table contains rows first:
protected void Page_Load(object sender, EventArgs e)
{
if (Session["empno"] != null)
empno = int.Parse(Session["empno"].ToString());
if (!IsPostBack)
{
var ds = AddPoliciesOnEmployees.GetPolicyOnEmployee(empno);
if (ds.Tables[0].Rows.Count > 0)
{
DataRow r = ds.Tables[0].Rows[0];
Label7.Text = r["policyname"].ToString();
Label8.Text = r["policyid"].ToString();
Label9.Text = r["policyamount"].ToString();
Label10.Text = r["TotalAmount"].ToString();
Label11.Text = r["pstartdate"].ToString();
}
}
}

Related

Data transfer between datagridviews c#

I am developing a project. In this project, the rows I selected from datagridview1 should be added to the child table and deleted from there. Later, I want to be able to add the rows that I don't want to pull from datagridview2 back to datagridview1. How do I do this?
Here is my codes:
private void button1_Click(object sender, EventArgs e)
{
con.Open();
SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM AçıkKalemler", con);
sda.Fill(dt);
dataGridView1.Rows.Clear();
foreach (DataRow item in dt.Rows)
{
int n = dataGridView1.Rows.Add();
dataGridView1.Rows[n].Cells[0].Value = false; // Select butonlarının seçili olmadan gelmesini sağlar.
dataGridView1.Rows[n].Cells[1].Value = item["MÜŞTERİ"].ToString();
dataGridView1.Rows[n].Cells[2].Value = item["SIPARISNUMARASI"].ToString();
dataGridView1.Rows[n].Cells[3].Value = item["SATISNUMARASI"].ToString();
dataGridView1.Rows[n].Cells[4].Value = item["KALEMTANIMI"].ToString();
dataGridView1.Rows[n].Cells[5].Value = item["PLANLANANTESLİMTARİHİ"].ToString();
dataGridView1.Rows[n].Cells[6].Value = item["SIPARISMIKTARI"].ToString();
}
}
private void button2_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow item in dataGridView1.Rows)
{
if ((bool)item.Cells[0].Value == true)
{
int n = dataGridView2.Rows.Add();
dataGridView2.Rows[n].Cells[0].Value = false;
dataGridView2.Rows[n].Cells[1].Value = item.Cells[1].Value.ToString();
dataGridView2.Rows[n].Cells[2].Value = item.Cells[2].Value.ToString();
dataGridView2.Rows[n].Cells[3].Value = item.Cells[3].Value.ToString();
dataGridView2.Rows[n].Cells[4].Value = item.Cells[4].Value.ToString();
dataGridView2.Rows[n].Cells[5].Value = item.Cells[5].Value.ToString();
dataGridView2.Rows[n].Cells[6].Value = item.Cells[6].Value.ToString();
}
private void dataGridView1_MouseClick(object sender, MouseEventArgs e)
{
if ((bool)dataGridView1.SelectedRows[0].Cells[0].Value == false)
{
dataGridView1.SelectedRows[0].Cells[0].Value = true;
}
else
{
dataGridView1.SelectedRows[0].Cells[0].Value = false;
}
}
private void button3_Click(object sender, EventArgs e)
{
foreach (DataGridViewRow item in dataGridView2.Rows)
{
if ((bool)item.Cells[0].Value == true)
{
int n = dataGridView1.Rows.Add();
dataGridView1.Rows[n].Cells[0].Value = false;
dataGridView1.Rows[n].Cells[1].Value = item.Cells[1].Value.ToString();
dataGridView1.Rows[n].Cells[2].Value = item.Cells[2].Value.ToString();
dataGridView1.Rows[n].Cells[3].Value = item.Cells[3].Value.ToString();
dataGridView1.Rows[n].Cells[4].Value = item.Cells[4].Value.ToString();
dataGridView1.Rows[n].Cells[5].Value = item.Cells[5].Value.ToString();
}
}
}
private void dataGridView2_MouseClick(object sender, MouseEventArgs e)
{
if ((bool)dataGridView2.SelectedRows[0].Cells[0].Value == false)
{
dataGridView2.SelectedRows[0].Cells[0].Value = true;
}
else
{
dataGridView2.SelectedRows[0].Cells[0].Value = false;
}
}
Button3 should do this.
Please help me!!

Updating/Deleting a row in listview that includes a countdown timer

Currently i am having trouble updating a row in my listview that contains both text and a timer that counts down. So far I've tried updating the entire row as well as trying to update just the text and i get an error in each instance.
System.ArgumentOutOfRangeException: InvalidArgument=Value of '0' is not valid for 'index
I am also having a slight problem with the delete button. It deletes the row as planned but it appears the information is still running in the background and haven't come across any info on how to delete the session. I pray for your guidance.
private void Confirm_Click(object sender, EventArgs e)
{
CSession newSession = new CSession();
if(PasswordText.Text == "")
{
MessageBox.Show("Password not entered");
return;
}
newSession.password = PasswordText.Text;
newSession.purchased_time = workingTimeSpan;
newSession.remaining_time = workingTimeSpan;
newSession.status = "Online";
sessionlist.Add(newSession);
PasswordText.Text = "";
TimerLabel.Text = "";
workingTimeSpan = new TimeSpan();
}
private void DisplayAllSessions()
{
listView1.Items.Clear();
foreach(CSession c in sessionlist)
{
string[] row = { c.password, c.purchased_time.ToString(), c.remaining_time.ToString(), c.status };
ListViewItem i = new ListViewItem(row);
listView1.Items.Add(i);
}
}
private void timer1_Tick(object sender, EventArgs e)
{
foreach(CSession c in sessionlist)
{
if (c.remaining_time.TotalMinutes == 5 && !c.MessageDisplayed)
{
c.MessageDisplayed = true;
MessageBox.Show("Time almost up for client.");
}
if (c.remaining_time.TotalSeconds < 1)
{
c.status = "Offline";
}
if(c.status == "Online")
{
c.remaining_time -= oneSecond;
}
}
DisplayAllSessions();
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Close();
}
private void Reset_Click(object sender, EventArgs e)
{
}
private void updatebutton()
{
listView1.SelectedItems[0].SubItems[0].Text = PasswordText.Text;
PasswordText.Text = "";
}
private void Update_Click(object sender, EventArgs e)
{
updatebutton();
}
private void listView1_SelectedIndexChanged(object sender, EventArgs e)
{
PasswordText.Text = listView1.SelectedItems[0].Text;
TimerLabel.Text = listView1.SelectedItems[0].SubItems[1].Text;
}
private void Delete_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Do you wish to delete.", "Removing User", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
listView1.Items.Clear();
timer1.Stop();
}
}
This is what i used for the update function and delete row function.
private void updatebutton()
{
CSession updatedsession = new CSession();
int updateindex = 0;
int index = 0;
foreach (CSession lookup in sessionlist)
{
if(lookup.password == PasswordText.Text)
{
if (MessageBox.Show("Do you wish to add time.", "Adding Time",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
updatedsession = lookup;
updateindex = index;
}
break;
}
index++;
}
updatedsession.purchased_time = workingTimeSpan +
updatedsession.purchased_time;
updatedsession.remaining_time = workingTimeSpan +
updatedsession.remaining_time;
sessionlist[updateindex] = updatedsession;
//sortedSessionList[PasswordText.Text] = updatedsession;
PasswordText.Text = "";
TimerLabel.Text = "";
workingTimeSpan = new TimeSpan();
}
private void Update_Click(object sender, EventArgs e)
{
updatebutton();
}
private void Delete_Click(object sender, EventArgs e)
{
CSession cSession = new CSession();
if (MessageBox.Show("Do you wish to delete.", "Removing User",
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
{
int index = 0;
foreach (CSession c in sessionlist)
{
if(c.password == PasswordText.Text)
{
break;
}
index++;
}
sessionlist.RemoveAt(index);
}
}

Can't find selected item in listbox C# ASP.NET

protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
//int test = Convert.ToInt32(ListBox1.SelectedValue.ToString());
//GetById(test);
foreach (ListItem listitem in ListBox1.Items)
{
if (listitem.Selected == true)
{
string email = listitem.Text;
GetByEmail(email);
}
}
}
This method should get selected item.I don't why but it show me that property selected is false for all items.
protected void Page_Load(object sender, EventArgs e)
{
ListBox1.Items.Clear();
SelectAllUsers();
}
public void SelectAllUsers()
{
SchoolService.SchoolServiceClient client = new SchoolService.SchoolServiceClient();
SchoolService.User[] userArray = client.SelectAll(0);
int i = 0;
while (i < userArray.Length)
{
ListItem listItem = new ListItem();
listItem.Text = userArray[i].Email;
listItem.Value = userArray[i].Id.ToString();
ListBox1.Items.Add(listItem);
i++;
}
}
public void GetByEmail(string email)
{
SchoolService.SchoolServiceClient client = new SchoolService.SchoolServiceClient();
SchoolClient.SchoolService.User user = client.GetUserByEmail(email);
if ((user.FirstName != null) || (user.LastName != null) || (user.Address != null) ||
(user.City != null) || (user.Email != null) || (user.Password != null))
{
txtId.Text = user.Id.ToString();
txtFirstName.Text = user.FirstName.ToString();
txtLastName.Text = user.LastName.ToString();
txtAddress.Text = user.Address.ToString();
txtCity.Text = user.City.ToString();
txtDateOfBirth.Text = user.DateOfBirth.ToShortDateString();
txtEmail.Text = user.Email.ToString();
txtPassword.Text = user.Password.ToString();
txtIsAdmin.Text = user.isAdmin.ToString();
}
else
{
MsgBox("None user was found", this.Page, this);
}
}
public void SelectAllUsers()
{
SchoolService.SchoolServiceClient client = new SchoolService.SchoolServiceClient();
SchoolService.User[] userArray = client.SelectAll(0);
int i = 0;
while (i < userArray.Length)
{
//if (userArray[i] != null)
//{
ListItem listItem = new ListItem();
listItem.Text = userArray[i].Email;
listItem.Value = userArray[i].Id.ToString();
ListBox1.Items.Add(listItem);
//}
i++;
}
}
Also sent methods which fill listBox with items (SelectAllUsers), and method which should take selected item from database (GetByEmail)
It doesn't find anything selected because on Page_Load you are rebinding the data again every time. You need to check if IsPostBack
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
ListBox1.Items.Clear();
SelectAllUsers();
}
}

Assigning checkbox a value from gridview

I am selecting a row from Gridview, working good except for checkbox, like I am assigning value of checkbox retreived from gridview to checkbox that is placed on web form but it isn't represented by checkbox on form, it shows empty checkbox in every case
if (gridviewDesignations.SelectedRow.Cells[5].Text == " ")
{
chkIsHead.Text = gridviewDesignations.SelectedRow.Cells[5].Text;
}
in short, checkbox is not picking value from gridview
Update:
tried this too:
CheckBox chkIsHead = (CheckBox) gridviewDesignations.SelectedRow.Cells[5].Controls[0];
if (chkIsHead.Checked == false)
{
chkIsHead.Checked = false;
}
else
{
chkIsHead.Checked = true;
}
Update:
my full code:
public partial class frmDesignations : System.Web.UI.Page
{
AccessibleVariables accessVariables = new AccessibleVariables(); //Used to access global variables
public void Clear(params TextBox[] txtBoxes)
{
foreach (TextBox txtbx in txtBoxes)
{
txtbx.Text = "";
}
}
public void fillddlDepartments()
{
ManageDepartmentsBizz mngDepBizz = new ManageDepartmentsBizz();
DataSet ds = (DataSet)mngDepBizz.SelectDepartments();
if (ds.Tables[0].Rows.Count != 0)
{
ddlDepartments.DataValueField = "DepID";
ddlDepartments.DataTextField = "DepName";
ddlDepartments.DataSource = ds.Tables[0];
// ddlDepartments.SelectedIndex = -1;
ddlDepartments.DataBind();
ddlDepartments.Items.Insert(0, "--Select--");
}
//else
// ddlDepartments.SelectedIndex = -1;
}
protected void Page_Load(object sender, EventArgs e)
{
if (Session.Count <= 0)
{
Response.Redirect("login.aspx");
}
lblMsgPopUp.Visible = false;
if (!IsPostBack)
{
fillddlDepartments();
}
}
protected void btnSave_Click(object sender, EventArgs e)
{
try
{
int DepartmentID = Convert.ToInt32(ddlDepartments.SelectedValue);
bool IsHead = Convert.ToBoolean(chkIsHead.Checked);
DesignationsBizz DesigBizz = new DesignationsBizz(-1, txtTitle.Text, DepartmentID, txtContactNo.Text, IsHead);
//-1 is bogus,used to fill parameters criteria i.e no of params
ManageDesignationsBizz mngDesigBizz = new ManageDesignationsBizz();
bool Result = mngDesigBizz.Insert(DesigBizz);
if (Result == true)
{
HiddenFieldSetMessage.Value = "Saved";
HiddenFieldShowMessage.Value = "True";
Clear(txtTitle, txtSelectedID, txtContactNo);
}
else
{
HiddenFieldSetMessage.Value = "RecordAlreadyExists";
HiddenFieldShowMessage.Value = "True";
}
}
catch (Exception)
{
HiddenFieldSetMessage.Value = "NotSaved";
HiddenFieldShowMessage.Value = "True";
}
}
protected void btnSearchPopup_Click(object sender, EventArgs e)
{
string DesignationTitle = txtDesignationPopUp.Text;
ManageDesignationsBizz mngDepsBizz = new ManageDesignationsBizz();
DataSet ds = (DataSet)mngDepsBizz.Select(DesignationTitle);
if (ds.Tables[0].Rows.Count != 0)
{
lblMsgPopUp.Visible = false;
gridviewDesignations.DataSource = ds.Tables[0];
gridviewDesignations.DataBind();
gridviewDesignations.Visible = true;
}
else
{
lblMsgPopUp.Visible = true;
gridviewDesignations.Visible = false;
}
}
protected void gridviewDesignations_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
string DesignationTitle = txtDesignationPopUp.Text;
ManageDesignationsBizz mngDepBizz = new ManageDesignationsBizz();
DataSet ds = (DataSet)mngDepBizz.Select(DesignationTitle);
if (ds.Tables[0].Rows.Count != 0)
{
gridviewDesignations.PageIndex = e.NewPageIndex;
gridviewDesignations.DataSource = ds.Tables[0];
gridviewDesignations.DataBind();
gridviewDesignations.Visible = true;
}
}
protected void btnEdit_Click(object sender, EventArgs e)
{
if (gridviewDesignations.SelectedRow != null)
{
if (gridviewDesignations.SelectedRow.Cells[1].Text == " ")
{
txtSelectedID.Text = string.Empty;
}
else
{
txtSelectedID.Text = gridviewDesignations.SelectedRow.Cells[1].Text;
}
if (gridviewDesignations.SelectedRow.Cells[2].Text == " ")
{
txtTitle.Text = string.Empty;
}
else
{
txtTitle.Text = gridviewDesignations.SelectedRow.Cells[2].Text;
}
if (gridviewDesignations.SelectedRow.Cells[3].Text == " ")
{
ddlDepartments.SelectedValue = string.Empty;
}
else
{
ddlDepartments.SelectedValue = gridviewDesignations.SelectedRow.Cells[3].Text;
accessVariables.DepID = Convert.ToInt32(gridviewDesignations.SelectedRow.Cells[3].Text);
ViewState["depID"] = accessVariables.DepID;
}
if (gridviewDesignations.SelectedRow.Cells[4].Text == " ")
{
txtContactNo.Text = string.Empty;
}
else
{
txtContactNo.Text = gridviewDesignations.SelectedRow.Cells[4].Text;
}
CheckBox chkIsHead = (CheckBox) gridviewDesignations.SelectedRow.Cells[5].Controls[0];
if (chkIsHead.Checked == false)
{
chkIsHead.Checked = false;
}
else
{
chkIsHead.Checked = true;
}
gridviewDesignations.DataBind();
gridviewDesignations.SelectedIndex = -1;
HiddenFieldShowHideButtons.Value = "True";
}
}
protected void btnUpdatePopUp_Click(object sender, EventArgs e)
{
try
{
int id = Convert.ToInt32(txtSelectedID.Text);
int DepartmentID = Convert.ToInt32(ddlDepartments.SelectedValue);
bool IsHead = Convert.ToBoolean(chkIsHead.Checked);
DesignationsBizz DesigBizz = new DesignationsBizz(id, txtTitle.Text, DepartmentID, txtContactNo.Text, IsHead );
ManageDesignationsBizz mngDesigBizz = new ManageDesignationsBizz();
bool Result = mngDesigBizz.Update(DesigBizz);
if (Result == true)
{
HiddenFieldSetMessage.Value = "Updated";
HiddenFieldShowMessage.Value = "True";
Clear(txtSelectedID, txtTitle, txtContactNo);
}
else
{
HiddenFieldSetMessage.Value = "NotUpdated";
HiddenFieldShowMessage.Value = "True";
}
}
catch (Exception)
{
HiddenFieldSetMessage.Value = "NotUpdated";
HiddenFieldShowMessage.Value = "True";
}
}
protected void btnDeletePopUp_Click(object sender, EventArgs e)
{
try
{
int ID = Convert.ToInt32(txtSelectedID.Text.Trim());
ManageDesignationsBizz mngDepBizz = new ManageDesignationsBizz();
mngDepBizz.Delete(ID);
Clear(txtTitle, txtSelectedID, txtContactNo);
HiddenFieldSetMessage.Value = "Deleted";
HiddenFieldShowMessage.Value = "True";
}
catch (Exception)
{
HiddenFieldSetMessage.Value = "NotDeleted";
HiddenFieldShowMessage.Value = "True";
}
}
protected void btnClosePopup_Click(object sender, EventArgs e)
{
Clear(txtTitle, txtSelectedID, txtContactNo);
}
protected void ddlDepartments_SelectedIndexChanged(object sender, EventArgs e)
{
if (txtSelectedID.Text != "")
{
accessVariables.DepID = Convert.ToInt32(ddlDepartments.SelectedValue);
ViewState["depID"] = accessVariables.DepID;
}
else
{
accessVariables.DepID = Convert.ToInt32(ddlDepartments.SelectedValue);
ViewState["depID"] = accessVariables.DepID;
}
}
protected void chkIsHead_CheckedChanged(object sender, EventArgs e)
{
if (txtSelectedID.Text != "")
{
int DepID = Convert.ToInt32(ViewState["depID"]);
ManageDesignationsBizz mngDesig = new ManageDesignationsBizz();
bool isHead = mngDesig.SelectIsHeadExistsByDepID(DepID);
if (isHead == true)
{
HiddenFieldSetMessage.Value = "HeadExists";
HiddenFieldShowMessage.Value = "True";
chkIsHead.Checked = false;
}
}
else
{
int DepID = Convert.ToInt32(ViewState["depID"]);
ManageDesignationsBizz mngDesig = new ManageDesignationsBizz();
bool isHead = mngDesig.SelectIsHeadExistsByDepID(DepID);
if (isHead == true)
{
HiddenFieldSetMessage.Value = "HeadExists";
HiddenFieldShowMessage.Value = "True";
chkIsHead.Checked = false;
}
}
}
}
I believe the following is what you need to do:
Then select EditProgrammatically.
I'm not sure if yoou'll need to manually put data into the grid though but that won't be too hard. Examples can be seen here : http://msdn.microsoft.com/en-us/library/system.data.datatable(v=vs.110).aspx
PS : You can set the DataSource in the grid view to the DataTable.

Parent Node is also unchecked if I uncheck a single childnode in treeview, but other childnode also checked

I have a treeview in my asp.net page, when i unselect a single child node and other node are selected then parent node is always unselected. If I unselected one more child node and again select it then parent node also select. I don't no why this problem occurs ?
==================================================================================
public partial class frmTabMenuManagement : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindMenu();
}
}
public void BindMenu()
{
AdminMenuLogic al = new AdminMenuLogic();
al.Description = "";
ddlParentMenu.DataSource = al.FilterAdminMenu();
ddlParentMenu.DataTextField = "Description";
ddlParentMenu.DataValueField = "Id";
ddlParentMenu.DataBind();
ddlParentMenu.Items.Insert(0, new ListItem("As Parent", "0"));
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
AdminMenuLogic amt = new AdminMenuLogic();
if (btnSubmit.Text == "Submit")
{
if (txtMenuLink.Text == "")
{
Response.Write("<script language='javascript'>alert(' Menu Description Cannot be left Empty');</script>");
}
else if (txtDestinationLink.Text == "")
{
Response.Write("<script language='javascript'>alert(' Destination Link Cannot be left Empty');</script>");
}
else
{
amt.Description = txtMenuLink.Text;
amt.IsActive = Convert.ToString(ddlIsActive.SelectedItem);
amt.Url = txtDestinationLink.Text;
amt.Parent = Convert.ToInt32(ddlParentMenu.SelectedValue);
amt.saveAdminMenu();
Response.Write("<script language='javascript'>alert('" + amt.OutPut + "');</script>");
txtMenuLink.Text = "";
txtDestinationLink.Text = "";
BindMenu();//reflect instant changes
}
}
else if (btnSubmit.Text == "Update")
{
amt.id = Convert.ToInt32(gvSearch.SelectedRow.Cells[1].Text);
amt.Description = txtMenuLink.Text;
amt.IsActive = Convert.ToString(ddlIsActive.SelectedItem);
amt.Url = txtDestinationLink.Text;
amt.Parent = Convert.ToInt32(ddlParentMenu.SelectedValue);
amt.UpdateAdminMenu();
Response.Write("<script language='javascript'>alert('" + amt.OutPut + "');</script>");
txtMenuLink.Text = "";
txtDestinationLink.Text = "";
bindGrid();
btnSubmit.Text = "Submit";
BindMenu();//reflect instant changes
}
}
protected void btnSearch_Click(object sender, EventArgs e)
{
if (btnSubmit.Text == "Update")
{
btnSubmit.Text = "Submit";
txtMenuLink.Text = "";
txtDestinationLink.Text = "";
}
bindGrid();
}
protected void gvSearch_SelectedIndexChanged(object sender, EventArgs e)
{
TabContainer1.ActiveTabIndex = 0;
ddlParentMenu.Items.Add(gvSearch.SelectedRow.Cells[3].Text);
ddlParentMenu.SelectedValue = gvSearch.SelectedRow.Cells[3].Text;
txtMenuLink.Text = Regex.Replace(gvSearch.SelectedRow.Cells[2].Text, "amp;", "");
txtDestinationLink.Text = Regex.Replace(gvSearch.SelectedRow.Cells[4].Text, "amp;", "");
ddlIsActive.SelectedValue = gvSearch.SelectedRow.Cells[5].Text;
btnSubmit.Text = "Update";
}
protected void txtMenuLink_TextChanged(object sender, EventArgs e)
{
if (char.IsWhiteSpace(txtMenuLink.Text.First()))
{
txtMenuLink.Text = Regex.Replace(txtMenuLink.Text, " ", "");
}
}
protected void txtDestinationLink_TextChanged(object sender, EventArgs e)
{
try
{
if (char.IsWhiteSpace(txtDestinationLink.Text.First()))
{
txtDestinationLink.Text = Regex.Replace(txtDestinationLink.Text, " ", "");
}
}
catch (Exception ex)
{
}
}
protected void ddlParentMenu_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void gvSearch_RowDataBound(Object sender, GridViewRowEventArgs e)
{
GridViewRow row = e.Row;
if (row.RowType == DataControlRowType.Header)
{
e.Row.Cells[1].Visible = false;
// e.Row.Cells[3].Visible = false;
}
if (row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[1].Visible = false;
// e.Row.Cells[3].Visible = false;
}
}
protected void gvSearch_PageIndexChanging(Object sender, GridViewPageEventArgs e)
{
gvSearch.PageIndex = e.NewPageIndex;
bindGrid();
}
protected void gvSearch_PageIndexChanged(Object sender, EventArgs e)
{
}
void bindGrid()
{
AdminMenuLogic al = new AdminMenuLogic();
al.Description = txtSearch.Text;
gvSearch.DataSource = al.FilterAdminMenu();
gvSearch.DataBind();
}
protected void ddlIsActive_SelectedIndexChanged(object sender, EventArgs e)
{
}
}

Categories

Resources