invalid postback event instead of dropdown to datagrid
Posted
by
rima
on Stack Overflow
See other posts from Stack Overflow
or by rima
Published on 2013-10-14T03:31:12Z
Indexed on
2013/10/24
21:55 UTC
Read the original article
Hit count: 222
I faced with funny situation. I created a page which is having some value, I set these value and control my post back event also. The problem is happening when I change a component index(ex reselect a combobox which is not inside my datagrid) then I dont know why without my page call the Page_Load it goes to create a new row in grid function and all of my parameter are null! I am just receiving null exception.
So in other word I try to explain the situation: when I load my page I am initializing some parameter. then everything is working fine. in my page when I change selected item of my combo box, page suppose to go and run function related to that combo box, and call page_load, but it is not going there and it goes to rowcreated function.
I am trying to illustrate part of my page. Please help me because I am not receiving any error except null exception and it triger wrong even which seems so complicated for me.
public partial class W_CM_FRM_02 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack && !loginFail)
return;
InitializeItems();
}
}
private void InitializeItems()
{
cols = new string[] { "v_classification_code", "v_classification_name" };
arrlstCMMM_CLASSIFICATION = (ArrayList)db.Select(cols, "CMMM_CLASSIFICATION", "v_classification_code <> 'N'", " ORDER BY v_classification_name");
}
}
protected void DGV_RFA_DETAILS_RowCreated(object sender, GridViewRowEventArgs e)
{
//db = (Database)Session["oCon"];
foreach (DataRow dr in arrlstCMMM_CLASSIFICATION)
((DropDownList)DGV_RFA_DETAILS.Rows[index].Cells[4].FindControl("OV_RFA_CLASSIFICATION")).Items.Add(new ListItem(dr["v_classification_name"].ToString(), dr["v_classification_code"].ToString()));
}
protected void V_CUSTOMER_SelectedIndexChanged(object sender, EventArgs e)
{
if (V_CUSTOMER.SelectedValue == "xxx" || V_CUSTOMER.SelectedValue == "ddd")
V_IMPACTED_FUNCTIONS.Enabled = true;
}
}
my form:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="W_CM_FRM_02.aspx.cs"
Inherits="W_CM_FRM_02" Title="W_CM_FRM_02" enableeventvalidation="false" EnableViewState="true"%>
<td>Project name*</td>
<td><asp:DropDownList ID="V_CUSTOMER" runat="server" AutoPostBack="True"
onselectedindexchanged="V_CUSTOMER_SelectedIndexChanged" /></td>
<td colspan = "8">
<asp:GridView ID="DGV_RFA_DETAILS" runat="server" ShowFooter="True" AutoGenerateColumns="False"
CellPadding="1" ForeColor="#333333" GridLines="None" OnRowDeleting="grvRFADetails_RowDeleting"
Width="100%" Style="text-align: left"
onrowcreated="DGV_RFA_DETAILS_RowCreated">
<RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
<Columns>
<asp:BoundField DataField="ON_RowNumber" HeaderText="SNo" />
<asp:TemplateField HeaderText="RFA/RAD/Ticket No*">
<ItemTemplate>
<asp:TextBox ID="OV_RFA_NO" runat="server" Width="120"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
© Stack Overflow or respective owner