Hello,
I have a requirement where in if the user clicks on the 'Add new' button to add a new row without choosing values from the 2 dropdownlists, then he/she should receive a prompt message.
Would someone know how to achieve this functionality ?
Please find the default.aspx.cs file attached. I have attached the html file in the next post.
Thanks.
using System;
using System.Data;
using System.Configuration;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Globalization;
using System.Text.RegularExpressions;
using System.Security.Principal; // here is the security namespace you need
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Specialized;
using System.Text;
namespace GISA
{
public partial class Default : System.Web.UI.Page
{
private string GetConnectionString()
{
return ConfigurationManager.ConnectionStrings["GISAConnectionString"].ConnectionString;
}
private void ShowNoResultFound(DataTable source, GridView gv)
{
source.Rows.Add(source.NewRow()); // create a new blank row to the DataTable
// Bind the DataTable which contain a blank row to the GridView
gv.DataSource = source;
gv.DataBind();
// Get the total number of columns in the GridView to know what the Column Span should be
int columnsCount = gv.Columns.Count;
gv.Rows[0].Cells.Clear(); // clear all the cells in the row
gv.Rows[0].Cells.Add(new TableCell()); //add a new blank cell
gv.Rows[0].Cells[0].ColumnSpan = columnsCount; //set the column span to the new added cell
//You can set the styles here
gv.Rows[0].Cells[0].HorizontalAlign = HorizontalAlign.Center;
gv.Rows[0].Cells[0].ForeColor = System.Drawing.Color.Red;
gv.Rows[0].Cells[0].Font.Bold = true;
//set No Results found to the new added cell
gv.Rows[0].Cells[0].Text = "NO RECORD FOUND!";
}
private void BindGridView()
{
DataTable dt = new DataTable();
SqlConnection connection = new SqlConnection(GetConnectionString());
try
{
connection.Open();
SqlCommand sqlCmd =
new SqlCommand(
"SELECT Row_Id,function_name,[SUB_FUNCTION], system_name, [DIRECTION],[REMOTE_SYSTEM],[INTERFACE_METHOD],[LAST_UPDATE_DT],[LAST_UPDATE_USER],[CREATE_DT],[CREATE_USER] FROM header WHERE office_cd = @Value1 AND trade_cd = @Value2",
connection);
string OfficeCd = "";
if (Office_cd.SelectedItem != null)
{
OfficeCd = Office_cd.SelectedItem.Text;
}
string TradeCd = "";
if (trade_cd.SelectedItem != null)
{
TradeCd = trade_cd.SelectedItem.Text;
}
sqlCmd.Parameters.AddWithValue("@Value1", OfficeCd);
sqlCmd.Parameters.AddWithValue("@Value2", TradeCd);
SqlDataAdapter sqlDa = new SqlDataAdapter(sqlCmd);
sqlDa.Fill(dt);
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
else
{
ShowNoResultFound(dt, GridView1);
}
GridView1.FooterRow.Visible = false;
GridView1.Columns[GridView1.Columns.Count - 1].Visible = false;
hdnNewRecordRequsted.Value = "0";
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Fetch Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
connection.Close();
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.BuilOrgList();
this.BuildOfficeAndTradeddl();
}
EnableDisableInsertionColumn();
}
protected void buttncancel_Click(object sender, EventArgs e)
{
Response.Redirect("Default.aspx");
}
protected void BuildOfficeAndTradeddl()
{
DataSet ds = new DataSet();
SqlConnection connection = new SqlConnection(GetConnectionString());
SqlDataAdapter sqlDa = new SqlDataAdapter(" SELECT distinct [TRADE_CD] FROM [business_area]", connection);
try
{
sqlDa.Fill(ds);
// Bind the trade
trade_cd.DataSource = ds.Tables[0];
trade_cd.DataBind();
}
catch (Exception ex)
{
throw new Exception("Office/Trade data fetch Error" + ex.Message);
}
finally
{
connection.Close();
}
}
protected DataTable GetFunctionNames()
{
DataTable dt = new DataTable();
using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
string sql = "SELECT DISTINCT FUNCTION_NAME FROM [SUB_FUNCTION]";
using (SqlCommand cmd = new SqlCommand(sql, connection))
{
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
}
}
return dt;
}
protected DataTable GetSubFunctionNames(string functionName)
{
DataTable dt = new DataTable();
using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
string sql = "Select Sub_function_id,Sub_Function_name from SUB_FUNCTION where Function_name='"+ functionName + "'";
using (SqlCommand cmd = new SqlCommand(sql, connection))
{
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
}
}
return dt;
}
protected DataTable GetSystemNames()
{
DataTable dt = new DataTable();
using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
string sql = "SELECT DISTINCT SYSTEM_NAME FROM SYSTEM";
using (SqlCommand cmd = new SqlCommand(sql, connection))
{
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
}
}
return dt;
}
protected DataTable GetInterfaceNames()
{
DataTable dt = new DataTable();
using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
string sql = "SELECT DISTINCT INTERFACE_METHOD FROM INTERFACE_METHOD";
using (SqlCommand cmd = new SqlCommand(sql, connection))
{
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
}
}
return dt;
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
BindGridView();
if ((DataControlRowState.Edit) > 0)
{
GridViewRow currentRow = this.GridView1.Rows[e.NewEditIndex];
// Find the update button and Set the confirmation message
int cellcount = currentRow.Cells.Count - 2;
Button btnupdate = currentRow.Cells[cellcount].Controls[0] as Button;
if (btnupdate != null)
{
btnupdate.Attributes.Add(
"onclick","return confirm('Do you wish to update selected row?');");
}
DataTable dtFunction = GetFunctionNames();
DropDownList ddlfunction_name = currentRow.FindControl("ddlfunction_name") as DropDownList;
ddlfunction_name.DataSource = dtFunction;
ddlfunction_name.DataTextField = "FUNCTION_NAME";
ddlfunction_name.DataValueField = "FUNCTION_NAME";
ddlfunction_name.DataBind();
// code to pre select in edit mode.
HiddenField hdnfunction_name = currentRow.FindControl("hdnfunction_name") as HiddenField;
if (hdnfunction_name != null)
{
ListItem foundnode = ddlfunction_name.Items.FindByText(hdnfunction_name.Value);
if (foundnode != null)
{
foundnode.Selected = true;
DropDownList ddlSub_Function = currentRow.FindControl("ddlSub_Function") as DropDownList;
DataTable dtsubfunction = this.GetSubFunctionNames(foundnode.Text);
ddlSub_Function.DataSource = dtsubfunction;
ddlSub_Function.DataTextField = "Sub_Function_name";
ddlSub_Function.DataValueField = "Sub_function_id";
ddlSub_Function.DataBind();
// code to pre select in edit mode.
HiddenField hdnSub_Function = currentRow.FindControl("hdnSub_Function") as HiddenField;
if (hdnSub_Function != null)
{
ListItem foundSubFunctionnode = ddlSub_Function.Items.FindByText(hdnSub_Function.Value);
if (foundSubFunctionnode != null)
{
foundSubFunctionnode.Selected = true;
}
}
}
}
DataTable dtSyatem = GetSystemNames();
DropDownList ddlsystem_name = currentRow.FindControl("ddlsystem_name") as DropDownList;
ddlsystem_name.DataSource = dtSyatem;
ddlsystem_name.DataTextField = "SYSTEM_NAME";
ddlsystem_name.DataValueField = "SYSTEM_NAME";
ddlsystem_name.DataBind();
// code to pre select in edit mode.
HiddenField hdnsystem_name = currentRow.FindControl("hdnsystem_name") as HiddenField;
if (hdnsystem_name != null)
{
ListItem foundnode = ddlsystem_name.Items.FindByText(hdnsystem_name.Value);
if (foundnode != null)
{
foundnode.Selected = true;
}
}
DropDownList ddlRemote_system = currentRow.FindControl("ddlRemote_system") as DropDownList;
ddlRemote_system.DataSource = dtSyatem;
ddlRemote_system.DataTextField = "SYSTEM_NAME";
ddlRemote_system.DataValueField = "SYSTEM_NAME";
ddlRemote_system.DataBind();
// code to pre select in edit mode.
HiddenField hdnRemote_system = currentRow.FindControl("hdnRemote_system") as HiddenField;
if (hdnRemote_system != null)
{
ListItem foundnode = ddlRemote_system.Items.FindByText(hdnRemote_system.Value);
if (foundnode != null)
{
foundnode.Selected = true;
}
}
DataTable dtInterface = GetInterfaceNames();
DropDownList ddlMethod = currentRow.FindControl("ddlMethod") as DropDownList;
ddlMethod.DataSource = dtInterface;
ddlMethod.DataTextField = "INTERFACE_METHOD";
ddlMethod.DataValueField = "INTERFACE_METHOD";
ddlMethod.DataBind();
HiddenField hdnMethod = currentRow.FindControl("hdnMethod") as HiddenField;
if (hdnMethod != null)
{
ListItem foundnode = ddlMethod.Items.FindByText(hdnMethod.Value);
if (foundnode != null)
{
foundnode.Selected = true;
}
}
DropDownList ddlDirection = currentRow.FindControl("ddlDirection") as DropDownList;
HiddenField hdnDirection = currentRow.FindControl("hdnDirection") as HiddenField;
if (hdnDirection != null)
{
ListItem foundnode = ddlDirection.Items.FindByText(hdnDirection.Value);
if (foundnode != null)
{
foundnode.Selected = true;
}
}
}
}
protected void btnAdd_Click(object sender, EventArgs e)
{
if (GridView1.FooterRow.Visible == false)
{
if (GridView1.Rows[0].Cells[0].Text == "NO RECORD FOUND!")
{
GridView1.Rows[0].Visible = false;
}
hdnNewRecordRequsted.Value = "1";
GridView1.FooterRow.Visible = true;
GridView1.Columns[GridView1.Columns.Count - 1].Visible = true;
}
}
private void UpdateOrAddNewRecord(
string ID,
string function_name,
string sub_function,
string System_name,
string Remote_system,
string INTERFACE_METHOD,
string Direction,
string userName,
bool isUpdate)
{
SqlConnection connection = new SqlConnection(GetConnectionString());
string sqlStatement = string.Empty;
string OfficeCd = "";
if (Office_cd.SelectedItem != null)
{
OfficeCd = Office_cd.SelectedItem.Text;
}
string TradeCd = "";
if (trade_cd.SelectedItem != null)
{
TradeCd = trade_cd.SelectedItem.Text;
}
if (!isUpdate)
{
sqlStatement =" INSERT INTO Header (TRADE_CD,FUNCTION_NAME,SUB_FUNCTION,SYSTEM_NAME,[REMOTE_SYSTEM],[INTERFACE_METHOD],[DIRECTION],OFFICE_CD,LAST_UPDATE_DT,LAST_UPDATE_USER,CREATE_DT,CREATE_USER) ";
sqlStatement += " VALUES ('" + TradeCd + "'";
sqlStatement += " ,'" + function_name + "'";
sqlStatement += " ,'" + sub_function + "'";
sqlStatement += " ,'" + System_name + "'";
sqlStatement += " ,'" + Remote_system + "'";
sqlStatement += " ,'" + INTERFACE_METHOD + "'";
sqlStatement += " ,'" + Direction + "'";
sqlStatement += " ,'" + OfficeCd + "'";
sqlStatement += " , getdate()";
sqlStatement += " ,'" + User.Identity.Name + "'";
sqlStatement += " , getdate()";
sqlStatement += " ,'" + User.Identity.Name + "'";
sqlStatement += ")";
}
else
{
sqlStatement = "update header set FUNCTION_NAME ='" + function_name + "'";
sqlStatement += ", SYSTEM_NAME ='" + System_name + "'";
sqlStatement += " , [SUB_FUNCTION]='" + sub_function + "' ,[REMOTE_SYSTEM] = '" + Remote_system + "'";
sqlStatement += " , [DIRECTION]='" + Direction + "' ,[INTERFACE_METHOD] = '" + INTERFACE_METHOD + "'";
sqlStatement += " , [LAST_UPDATE_DT]=getdate() ,[LAST_UPDATE_USER] = '" + User.Identity.Name + "'";
sqlStatement += " where ROW_ID =" + ID;
}
try
{
connection.Open();
SqlCommand cmd = new SqlCommand(sqlStatement, connection);
cmd.ExecuteNonQuery();
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Insert/Update Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
connection.Close();
}
}
protected void Find_Click(object sender, EventArgs e)
{
PerformFindAction();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string row_id = string.Empty,
function_name = string.Empty,
sub_function = string.Empty,
system_name = string.Empty,
Remote_system = string.Empty,
Direction = string.Empty,
INTERFACE_METHOD = string.Empty;
GridViewRow currentRow = GridView1.Rows[e.RowIndex];
Label lblRow_ID = currentRow.FindControl("lblRow_ID") as Label;
if (lblRow_ID != null)
{
row_id = lblRow_ID.Text;
}
DropDownList ddlfunction_name = currentRow.FindControl("ddlfunction_name") as DropDownList;
if (ddlfunction_name != null)
{
if (ddlfunction_name.SelectedItem != null)
{
function_name = ddlfunction_name.SelectedItem.Value;
function_name = ddlfunction_name.SelectedItem.Text;
}
}
DropDownList ddlSub_Function = currentRow.FindControl("ddlSub_Function") as DropDownList;
if (ddlSub_Function != null)
{
if (ddlSub_Function.SelectedItem != null)
{
sub_function = ddlSub_Function.SelectedItem.Text;
}
}
DropDownList ddlsystem_name = currentRow.FindControl("ddlsystem_name") as DropDownList;
if (ddlsystem_name != null)
{
if (ddlsystem_name.SelectedItem != null)
{
system_name = ddlsystem_name.SelectedItem.Value;
system_name = ddlsystem_name.SelectedItem.Text;
}
}
DropDownList ddlRemote_system = currentRow.FindControl("ddlRemote_system") as DropDownList;
if (ddlRemote_system != null)
{
if (ddlRemote_system.SelectedItem != null)
{
Remote_system = ddlRemote_system.SelectedItem.Text;
}
}
DropDownList ddlMethod = currentRow.FindControl("ddlMethod") as DropDownList;
if (ddlMethod != null)
{
if (ddlMethod.SelectedItem != null)
{
INTERFACE_METHOD = ddlMethod.SelectedItem.Text;
}
}
DropDownList ddldirection = currentRow.FindControl("ddldirection") as DropDownList;
if (ddldirection != null)
{
if (ddldirection.SelectedItem != null)
{
Direction = ddldirection.SelectedItem.Text;
}
}
UpdateOrAddNewRecord(
row_id,
function_name,
sub_function,
system_name,
Remote_system,
INTERFACE_METHOD,
Direction,"Dummy Update User",
true);
GridView1.EditIndex = -1;
BindGridView();
}
protected void CancelEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindGridView();
}
private void DeleteRecord(string ID)
{
if (!string.IsNullOrEmpty(ID))
{
SqlConnection connection = new SqlConnection(GetConnectionString());
string sqldelete = " DELETE FROM header WHERE ROW_ID IN ( " + ID + ")";
try
{
connection.Open();
SqlCommand cmd = new SqlCommand(sqldelete, connection);
cmd.ExecuteNonQuery();
}
catch (System.Data.SqlClient.SqlException ex)
{
string msg = "Deletion Error:";
msg += ex.Message;
throw new Exception(msg);
}
finally
{
connection.Close();
}
}
}
protected void btnDelete_Click(object sender, EventArgs e)
{
string selectedid = string.Empty;
foreach (GridViewRow gridrow in GridView1.Rows)
{
CheckBox chkselecttodelte = gridrow.FindControl("chkselecttodelte") as CheckBox;
Label lblrowid = gridrow.FindControl("lblRow_ID") as Label;
if (chkselecttodelte != null)
{
if (chkselecttodelte.Checked)
{
if (string.IsNullOrEmpty(selectedid))
{
selectedid = lblrowid.Text;
}
else
{
selectedid += " ," + lblrowid.Text;
}
}
}
}
DeleteRecord(selectedid);
BindGridView();
}
protected void Add_Click(object sender, EventArgs e)
{
string function_name = string.Empty,
sub_function = string.Empty,
system_name = string.Empty,
Remote_system = string.Empty,
Direction = string.Empty,
INTERFACE_METHOD = string.Empty;
GridViewRow currentRow = GridView1.FooterRow;
DropDownList ddlfunction_name = currentRow.FindControl("ddlfooterfunction_name") as DropDownList;
if (ddlfunction_name != null)
{
if (ddlfunction_name.SelectedItem != null)
{
function_name = ddlfunction_name.SelectedItem.Value;
function_name = ddlfunction_name.SelectedItem.Text;
}
}
DropDownList ddlfooterSub_Function = currentRow.FindControl("ddlfooterSub_Function") as DropDownList;
if (ddlfooterSub_Function != null)
{
if (ddlfooterSub_Function.SelectedItem != null)
{
sub_function = ddlfooterSub_Function.SelectedItem.Text;
}
}
DropDownList ddlsystem_name = currentRow.FindControl("ddlfootersystem_name") as DropDownList;
if (ddlsystem_name != null)
{
if (ddlsystem_name.SelectedItem != null)
{
system_name = ddlsystem_name.SelectedItem.Value;
system_name = ddlsystem_name.SelectedItem.Text;
}
}
DropDownList ddlfooterRemote_system = currentRow.FindControl("ddlfooterRemote_system") as DropDownList;
if (ddlfooterRemote_system != null)
{
if (ddlfooterRemote_system.SelectedItem != null)
{
Remote_system = ddlfooterRemote_system.SelectedItem.Text;
}
}
DropDownList ddlfooterMethod = currentRow.FindControl("ddlfooterMethod") as DropDownList;
if (ddlfooterMethod != null)
{
if (ddlfooterMethod.SelectedItem != null)
{
INTERFACE_METHOD = ddlfooterMethod.SelectedItem.Text;
}
}
DropDownList ddlfooterdirection = currentRow.FindControl("ddlfooterdirection") as DropDownList;
if (ddlfooterdirection != null)
{
if (ddlfooterdirection.SelectedItem != null)
{
Direction = ddlfooterdirection.SelectedItem.Text;
}
}
UpdateOrAddNewRecord(
string.Empty,
function_name,
sub_function,
system_name,
Remote_system,
INTERFACE_METHOD,
Direction,"Dummy Add User",
false);
BindGridView();
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
BindGridView();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Footer)
{
GridViewRow currentRow = e.Row;
DataTable dtFunction = GetFunctionNames();
DropDownList ddlfunction_name = currentRow.FindControl("ddlfooterfunction_name") as DropDownList;
ddlfunction_name.DataSource = dtFunction;
ddlfunction_name.DataTextField = "FUNCTION_NAME";
ddlfunction_name.DataValueField = "FUNCTION_NAME";
ddlfunction_name.DataBind();
if (ddlfunction_name.SelectedItem != null)
{
DataTable dtsubfunction = this.GetSubFunctionNames(ddlfunction_name.SelectedItem.Text);
var ddlSubFunction = currentRow.FindControl("ddlfooterSub_Function") as DropDownList;
if (ddlSubFunction != null)
{
ddlSubFunction.DataSource = dtsubfunction;
ddlSubFunction.DataTextField = "Sub_Function_name";
ddlSubFunction.DataValueField = "Sub_function_id";
ddlSubFunction.DataBind();
}
}
DataTable dtSystem = GetSystemNames();
DropDownList ddlsystem_name = currentRow.FindControl("ddlfootersystem_name") as DropDownList;
ddlsystem_name.DataSource = dtSystem;
ddlsystem_name.DataTextField = "SYSTEM_NAME";
ddlsystem_name.DataValueField = "SYSTEM_NAME";
ddlsystem_name.DataBind();
DropDownList ddlfooterRemote_system = currentRow.FindControl("ddlfooterRemote_system") as DropDownList;
ddlfooterRemote_system.DataSource = dtSystem;
ddlfooterRemote_system.DataTextField = "SYSTEM_NAME";
ddlfooterRemote_system.DataValueField = "SYSTEM_NAME";
ddlfooterRemote_system.DataBind();
DataTable dtInterface = GetInterfaceNames();
DropDownList ddlMethod = currentRow.FindControl("ddlfooterMethod") as DropDownList;
ddlMethod.DataSource = dtInterface;
ddlMethod.DataTextField = "INTERFACE_METHOD";
ddlMethod.DataValueField = "INTERFACE_METHOD";
ddlMethod.DataBind();
}
}
private void BuilOrgList()
{
DataTable dt = new DataTable();
using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
string sql = "select Distinct [organization_cd] from minigapp..mg_Office where deleted_flg = 'N'";
using (SqlCommand cmd = new SqlCommand(sql, connection))
{
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
}
}
if (dt.Rows.Count > 0)
{
ddlOrgCode.DataSource = dt;
ddlOrgCode.DataTextField = "organization_cd";
ddlOrgCode.DataValueField = "organization_cd";
ddlOrgCode.DataBind();
}
}
protected void ddlOrgCode_SelectedIndexChanged(object sender, EventArgs e)
{
BuilOfficeList();
PerformFindAction();
}
private void BuilOfficeList()
{
DataTable dt = new DataTable();
var orgcode = "";
if (ddlOrgCode.SelectedItem != null)
{
orgcode = ddlOrgCode.SelectedItem.Text;
}
using (SqlConnection connection = new SqlConnection(GetConnectionString()))
{
string sql = "select Distinct office_cd from minigapp..mg_Office where deleted_flg = 'N' and organization_cd=@orgId";
using (SqlCommand cmd = new SqlCommand(sql, connection))
{
cmd.Parameters.AddWithValue("@orgId", orgcode);
SqlDataAdapter ad = new SqlDataAdapter(cmd);
ad.Fill(dt);
}
}
if (dt.Rows.Count > 0)
{
Office_cd.DataSource = dt;
Office_cd.DataTextField = "office_cd";
Office_cd.DataValueField = "office_cd";
Office_cd.DataBind();
}
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
}
/// <summary>
/// fill the sub function
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void DdlFunctionSelectedIndexChanged(object sender, EventArgs e)
{
var ddlfunction = sender as DropDownList;
if (ddlfunction != null)
{
if (ddlfunction.SelectedItem != null)
{
DataTable dtsubfunction = this.GetSubFunctionNames(ddlfunction.SelectedItem.Text);
var currentRow = (GridViewRow)ddlfunction.NamingContainer;
var ddlSubFunction = currentRow.FindControl("ddlSub_Function") as DropDownList;
if (ddlSubFunction != null)
{
ddlSubFunction.DataSource = dtsubfunction;
ddlSubFunction.DataTextField = "Sub_Function_name";
ddlSubFunction.DataValueField = "Sub_function_id";
ddlSubFunction.DataBind();
}
}
}
}
/// <summary>
/// fill the sub function
/// </summary>
/// <param name="sender">
/// The sender.
/// </param>
/// <param name="e">
/// The e.
/// </param>
protected void AddnewDdlFunctionSelectedIndexChanged(object sender, EventArgs e)
{
var ddlfunction = sender as DropDownList;
if (ddlfunction != null)
{
if (ddlfunction.SelectedItem != null)
{
DataTable dtsubfunction = this.GetSubFunctionNames(ddlfunction.SelectedItem.Text);
var currentRow = (GridViewRow)ddlfunction.NamingContainer;
var ddlSubFunction = currentRow.FindControl("ddlfooterSub_Function") as DropDownList;
if (ddlSubFunction != null)
{
ddlSubFunction.DataSource = dtsubfunction;
ddlSubFunction.DataTextField = "Sub_Function_name";
ddlSubFunction.DataValueField = "Sub_function_id";
ddlSubFunction.DataBind();
}
}
}
}
/// <summary>
/// code to Enable disable the row item template row ate time of Add new.
/// </summary>
private void EnableDisableInsertionColumn()
{
if (GridView1.Rows.Count == 1)
{
if (GridView1.Rows[0].Cells[0].Text == "NO RECORD FOUND!")
{
GridView1.Rows[0].Visible = false;
}
}
}
private void PerformFindAction()
{
gridContainer.Visible = true;
BindGridView();
}
protected void Office_cd_OnSelectedIndexChanged(object sender, EventArgs e)
{
PerformFindAction();
}
protected void trade_cd_OnSelectedIndexChanged(object sender, EventArgs e)
{
PerformFindAction();
}
}
}