C# .NET - Error: No overload for 'update_function' matches delegate 'System.EventHandler'
Asked By Nor Shahida Mohd Jamail on 12-Sep-06 11:34 PM
Hi,
<asp:DropDownList ID="drptwrDepartment" runat="server" AutoPostBack="true" OnSelectedIndexChanged ="update_function"
DataSource='<%#getDepartmentOptions()%>'
SelectedIndex='<%# GetSelectedIndex(DataBinder.Eval(Container.DataItem, "TWRDEPARTMENT" ),"DepartmentOptions") %>'>
</asp:DropDownList> </td>
protected
void update_function(object Sender, DataListCommandEventArgs e)
{
DropDownList drptwrDepartment = (DropDownList)e.Item.FindControl("drptwrDepartment");
DropDownList drpFunction = (DropDownList)e.Item.FindControl("drpFunction");
drpFunction.DataSource = twr.
twrUtil.LoadFunctionByDepartment(drptwrDepartment.SelectedValue.ToString());
drpFunction.DataTextField =
"FUNCTN_DESC";
drpFunction.DataValueField =
"FUNCTN_DESC";
drpFunction.DataBind();
}
On compliation, it is throwing the below error on line 1
"No overload for 'update_function' matches delegate 'System.EventHandler'"
why the error occured and how to solve it...Thank You
Sushila Patel replied to Nor Shahida Mohd Jamail on 12-Sep-06 11:39 PM
should be
protected void update_function(object Sender, EventArgs e)
'System.EventArgs' does not contain a definition for 'Item'
Nor Shahida Mohd Jamail replied to Sushila Patel on 12-Sep-06 11:56 PM
Cannot recognize the DataListCommandEventArgs for dropdownlist. The update_function is for OnSelectedIndexChange. How to function value when select the department (autoPostBack). Thank You
protected void update_function(object Sender, EventArgs e)
{
DropDownList drptwrDepartment = (DropDownList)e.Item.FindControl("drptwrDepartment");
DropDownList drpFunction = (DropDownList)e.Item.FindControl("drpFunction");
drpFunction.DataSource = twr.twrUtil.LoadFunctionByDepartment(drptwrDepartment.SelectedValue.ToString());
drpFunction.DataTextField = "FUNCTN_DESC";
drpFunction.DataValueField = "FUNCTN_DESC";
drpFunction.DataBind();
}
Sushila Patel replied to Nor Shahida Mohd Jamail on 13-Sep-06 12:01 AM
Where in code do you hsve DataListCommandEventArgs
do you have ddl in datalist????
<%# GetSelectedIndex(DataBinder.Eval(Container.DataItem, "TWRDEPARTMENT" ),"DepartmentOptions") %>
ERROR:No overload for 'Update_function' matches delegate ' System.EventHandler'.
Nor Shahida Mohd Jamail replied to Sushila Patel on 13-Sep-06 12:30 AM
Below is the full code. Actually when update the record, the user will select the department at dropdownlist(ArrayList) and then, they will select the function based on the department(OnSelectedIndexChanged). But now the error is like No overload for 'Update_function' matches delegate ' System.EventHandler'. What should i do now. Please help me...Thank You
<asp:DropDownList ID="drptwrDepartment" runat="server" AutoPostBack="true" OnSelectedIndexChanged ="update_function"
DataSource='<%#getDepartmentOptions()%>'
SelectedIndex='<%# GetSelectedIndex(DataBinder.Eval(Container.DataItem, "TWRDEPARTMENT" ),"DepartmentOptions") %>'>
</asp:DropDownList> </td>
public partial class Maintenance_Wafer_Type : System.Web.UI.Page
{
public static OracleDataReader OracleRead = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
LoadWaferType();
}
}
protected void LoadWaferType()
{
string strSQL = "SELECT RECORD_KEY, TWRDEPARTMENT, WAFERTYPE, TWRFUNCTION FROM TWRWAFERTYPE ORDER BY TWRDEPARTMENT";
try
{
OracleRead = twr.
OracleHelper.ExecuteReader(twr.twrUtil.ConStr(), CommandType.Text, strSQL);
OracleDataReader dtrList2 = OracleRead;
dlstWaferType.DataSource = dtrList2;
dlstWaferType.DataBind();
}
catch (Exception exp)
{
twr.
ErrorLog.WriteError(exp.ToString());
}
}
protected void update_function(object Sender, DataListCommandEventArgs e)
{
DropDownList drptwrDepartment = (DropDownList)e.Item.FindControl("drptwrDepartment");
DropDownList drpFunction = (DropDownList)e.Item.FindControl("drpFunction");
drpFunction.DataSource = twr.
twrUtil.LoadFunctionByDepartment(drptwrDepartment.SelectedValue.ToString());
drpFunction.DataTextField =
"FUNCTN_DESC";
drpFunction.DataValueField =
"FUNCTN_DESC";
drpFunction.DataBind();
}
protected void WaferType_EditCommand(object Source, DataListCommandEventArgs e)
{
lblMessage.Text =
"";
dlstWaferType.EditItemIndex = (
int)e.Item.ItemIndex;
protected ArrayList getDepartmentOptions()
{
ArrayList arrList = new ArrayList();
try
{
string strSQL = "SELECT DISTINCT(DEPT_DESC) FROM HTRNADM.SM_DEPT_FUNCT_VIEW ORDER BY DEPT_DESC";
OracleRead = twr.
OracleHelper.ExecuteReader(twr.twrUtil.ConStrPplsoft(), CommandType.Text, strSQL.ToString());
}
catch (Exception e)
{
Trace.Write(e.Message.ToString());
}
while (OracleRead.Read())
{
arrList.Add(OracleRead[
"DEPT_DESC"]);}
OracleRead.Close();
Application.Add(
"DepartmentOptions", arrList);
return arrList;
}
protected ArrayList getFunctionOptions(object selectedValue, string optionName)
{
ArrayList options = (ArrayList)Application.Get(optionName);
int index = options.IndexOf(selectedValue.ToString());
ArrayList arrList2 = new ArrayList();
try
{
string strSQL = "SELECT FUNCTN_DESC FROM HTRNADM.SM_DEPT_FUNCT_VIEW WHERE DEPT_DESC='" + options[index] + "'";
OracleRead = twr.
OracleHelper.ExecuteReader(twr.twrUtil.ConStrPplsoft(), CommandType.Text, strSQL.ToString());
}
catch (Exception e)
{
Trace.Write(e.Message.ToString());
}
while (OracleRead.Read())
{
arrList2.Add(OracleRead[
"FUNCTN_DESC"]);
}
OracleRead.Close();
Application.Add(
"FunctionOptions", arrList2);
return arrList2;
}
protected int GetSelectedIndex(object selectedValue, string optionName)
{
ArrayList options = (ArrayList)Application.Get(optionName);
int index = options.IndexOf(selectedValue.ToString());
return index;
}
protected int GetSelectedIndex2(object selectedValue, string optionName)
{
ArrayList options = (ArrayList)Application.Get(optionName);
int index = options.IndexOf(selectedValue.ToString());
return index;
}
protected void WaferType_UpdateCommand(object Source, DataListCommandEventArgs e)
{
string itemKey = dlstWaferType.DataKeys[(int)e.Item.ItemIndex].ToString();
DropDownList drptwrDepartment = (DropDownList)e.Item.FindControl("drptwrDepartment");
TextBox TxtWaferType = (TextBox)e.Item.FindControl("TxtWaferType");
Label lblDepartment = (Label)e.Item.FindControl("lblDepartment");
Label lblWaferType = (Label)e.Item.FindControl("lblWaferType");
string sUser = twr.twrUtil.GetSessionUserName();
int exist = 0;
string strMsg = string.Empty;
string strChkExistSQL = "SELECT COUNT(*) TWRTOOLS WHERE TWRDEPARTMENT = '" + lblDepartment +
"' AND RECORD_KEY <> " + itemKey.ToString();
if (exist == 1)
{
strMsg = drptwrDepartment +
" already exists. Please disable the existing record to enter new value.";
}
else if (exist == 0)
{
string strSQL = "UPDATE TWRWAFERTYPE SET TWRDEPARTMENT = '" + drptwrDepartment.SelectedValue.ToString() +
"', WAFERTYPE = '" + TxtWaferType.Text.ToString() + "'" +
"WHERE RECORD_KEY= '" + itemKey.ToString() + "'";
OracleConnection con = new OracleConnection(twr.twrUtil.ConStr());
con.Open();
try
{
OracleCommand cmdSelect = con.CreateCommand();
cmdSelect =
new OracleCommand(strSQL, con);
cmdSelect.CommandType =
CommandType.Text;
cmdSelect.ExecuteNonQuery();
twr.
ErrorLog.WriteError("ExecuteNonQuery = " + strSQL.ToString());
strMsg =
"Record Updated.";
}
catch (Exception exp)
{
Trace.Write(exp.Message.ToString());
twr.
ErrorLog.WriteError("Error inserting record: " + exp.Message.ToString() + strSQL.ToString());
strMsg = exp.Message.ToString();
}
con.Close();
}
lblMessage.Text = strMsg;
dlstWaferType.EditItemIndex = -1;
LoadWaferType();
}

Create a DropDownList for Populating a TextBox ASP.NET 10-Aug-13 06 I need a textbox for entering new items & also a dropdownlist which should show already inserted items & by selecting the items title > < / head > < body > < form id = "form1" runat = "server" > < div > < asp:DropDownList ID = "DropDownList1" runat = "server" AutoPostBack = "true" OnSelectedIndexChanged = "SelectedIndexChanged" > < asp:ListItem Value = "Value 1" Text = "Value 1" / > < asp Text = "Value 4" / > < asp:ListItem Value = "Other" Text = "Other" / > < / asp:DropDownList > < asp:TextBox ID = "TextBox1" runat = "server" / > < / div > < / form > < / body > < / html in you code behind file public void SelectedIndexChanged( object sender, EventArgs e) { DropDownList dropDownList = (DropDownList)sender; if (dropDownList.SelectedValue = = "Other" ) { TextBox1.Enabled = true ; TextBox1
how to use dropdownlist for redirecting a new page ASP.NET 10-Aug-13 asp.net 2.0, c#. in my project iam using dropdownlist. In dropdownlist iam using 6 listitems, 1.offset 2.machinery etc. . when i click the offset listitem in dropdownlist by the click it should be redirected to new page that. Thanks in advance frndz! In your aspx page < asp:DropDownList runat = "server" id = "ddl" OnSelectedIndexChanged = "SelectionChanged" AutoPostBack = "true" > < asp:ListItem Text = "Page 1" Value = " / page1 aspx" / > < asp:ListItem Text = "Page 2" Value = " / page2.aspx" / > < / asp:DropDownList > And in your codebehind, the event handler we referenced in the "OnSelectedIndexChanged" property will get fired: protected void SelectionChanged(object sender, EventArgs
How find ddlName_SelectedIndexChanged evnt of a dropdownlist in GridView header row ? ASP.NET 10-Aug-13 06 16 PM hi friends, How find ddlName_SelectedIndexChanged evnt of a dropdownlist in GridView header row ? In which event i can write? Try like this- <HeaderTemplate> <asp:DropDownList ID = "drp" runat = "server OnSelectedIndexChanged = "drp_ SelectedIndexChanged " AutoPostBack = "true"> < / asp:DropDownList> < / HeaderTemplate> .cs code- protected void drp_ SelectedIndexChanged (object sender, EventArgs e) { string str = "hi"; } Try this and let me know and set Auto Postback True Logic : < asp : TemplateField > < HeaderTemplate > < asp : DropDownList ID = "ddlGrvStnHeader" OnSelectedIndexChanged = "ddlDropwDownlist_SelectedIndexChanged" AutoPostBack = "true" runat = "server" Width = "200px" > < asp : ListItem Text
46 PM Can anyone convert below coding to C#? <asp:DropDownList id = "cboState" OnSelectedIndexChanged = "PopulateNextCombo" AutoPostBack = "True" runat = "server" / > Public Sub PopulateNextCombo(ByVal sender As Object, ByVal e As System.EventArgs) Dim tmpcboState2 As DropDownList Dim tmpDropDown1 as DropDownList Dim myConnection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("ConnectionString")) Dim CloseConnection) tmpcboState2 = CType(DG_Combo.Items.Item(DG_Combo.EditItemIndex).FindControl("cboState2"), DropDownList) tmpcboState2.DataSource = myDataReader tmpcboState2.DataBind() tmpDropDown1 = CType(DG_Combo.Items.Item(DG_Combo.EditItemIndex).FindControl("cboState"), DropDownList) tmpcboState2.SelectedIndex = tmpDropDown1.SelectedIndex Catch SQLexc As SqlException lblStatus.Text check out the code public void PopulateNextCombo(object sender, System.EventArgs e) { DropDownList tmpcboState2; DropDownList tmpDropDown1; SqlConnection myConnection = new SqlConnection(ConfigurationSettings
ERROR: 'System.EventArgs' does not contain a definition for 'Item' C# .NET 10 Aug-13 06:46 PM Cannot recognize the DataListCommandEventArgs for dropdownlist. The update_function is for OnSelectedIndexChange. How to function value when select the department (autoPostBack). Thank You < asp : DropDownList ID = "drptwrDepartment" runat = "server" AutoPostBack = "true OnSelectedIndexChanged = "update_function" DataSource = ' <%#getDepartmentOptions()%> ' SelectedIndex = ' <%# GetSelectedIndex(DataBinder.Eval(Container.DataItem, "TWRDEPARTMENT" ), "DepartmentOptions") %> '> < / asp : DropDownList > < / td > < td class = "table1_row_3" align = "center" width = "5%"> < asp : DropDownList ID = "drpFunction" runat = "server" DataSource = ' <%#getFunctionOptions(DataBinder.Eval(Container.DataItem DepartmentOptions")%> ' SelectedIndex = ' <%# GetSelectedIndex2(DataBinder.Eval(Container.DataItem, "TWRFUNCTION" ), "FunctionOptions") %> '> < / asp : DropDownList > < / td > protected void update_function( object Sender, EventArgs e) { DropDownList drptwrDepartment = ( DropDownList )e.Item.FindControl( "drptwrDepartment" ); DropDownList drpFunction
e.Item.ItemType = = ListItemType.Item) { string[] options = {"Option1", "Option2", "Option3"}; DropDownList list = (DropDownList)e.Item.FindControl("ItemDropDown"); list.DataSource = options; list.DataBind(); } else { string[] options = {"OptionA", "OptionB", "OptionC"}; DropDownList list = (DropDownList)e.Item.FindControl("HeaderDropDown"); list.DataSource = options; list.DataBind(); } } protected void DropDown_SelectedIndexChanged(object sender, EventArgs e) { DropDownList list = (DropDownList)sender; TableCell cell = list.Parent as TableCell; DataGridItem item = cell asp:BoundColumn DataField = "au_fname" HeaderText = "au_fname" / > <asp:TemplateColumn> <HeaderTemplate> <asp:DropDownList ID = "HeaderDropDown" Runat = "server" AutoPostBack = "True" OnSelectedIndexChanged = "DropDown_SelectedIndexChanged" / > < / HeaderTemplate> <ItemTemplate
event handler of selecteIndexChanged and write the code: < ItemTemplate > < asp : DropDownList ID = "DropDownList3" runat = "server" onselectedindexchanged = "DropDownList3_SelectedIndexChanged" > < asp : ListItem > 1 < / asp : ListItem > < asp : ListItem > 2 < / asp ListItem > < asp : ListItem > 3 < / asp : ListItem > < / asp : DropDownList > < / ItemTemplate > protected void DropDownList3_SelectedIndexChanged( object sender, EventArgs e) { / / code } Use this code- < asp : GridView ID = "GridView1" runat server" AutoGenerateColumns = "false"> < Columns > < asp : TemplateField > < ItemTemplate > < asp : DropDownList runat = "server" ID = "DropDownList1" OnSelectedIndexChanged = "DropDownList1_SelectedIndexChanged"> < / asp : DropDownList > < / ItemTemplate > < / asp : TemplateField > < / Columns > < / asp : GridView > protected void DropDownList1_SelectedIndexChanged( object sender, EventArgs e) { DropDownList drp = sender as DropDownList ; / / Your code } Try this
Compile error on dropdownlist. C# .NET 10-Aug-13 06:43 PM I have Date Of Birth:< / legend> <span> <fieldset> <legend> DropDownListBindingDate< / legend> <asp:DropDownList ID = "DropDownList1" runat = "server" OnSelectedIndexChanged = "DropDownList1_Se lectedInde xChanged" AutoPostBack = "True"> < / asp:DropDownList> <asp:DropDownList ID = "DropDownList2" runat = "server" OnSelectedIndexChanged = "DropDownList2_Se lectedInde xChanged" AutoPostBack = "True"> < / asp DropDownList> <asp:DropDownList ID = "DropDownList3" runat = "server" AutoPostBack = "True"> < / asp:DropDownList> <br / > <asp
dropdownlist binding ASP.NET 10-Aug-13 06:24 PM Hi, I have two dropdownlist in my page for searching(second dropdown values depends on the first dropdownlist value) is it possible to bind the second dropdownlist based on the first dropdownlist without autopostback. is it possible by using updatepanel. . . . . CASCADING DROPDOWN UpdatePanel1" UpdateMode = "Conditional" runat = "server"> <ContentTemplate> <strong> Country : < / strong> <asp:DropDownList ID = "ddlCountry" runat = "server" AutoPostBack = "True" OnSelectedIndexChanged = "ddlCountry_SelectedIndexChanged"> < / asp:DropDownList> <br / > <br / > <strong> State: < / strong> <asp:DropDownList ID = "ddlState" runat