Hi every one...
in my web application, i have a gridview,in that gridview footer template i have a dropdownlist. I need to load the values in DB table on pageload.
but am not using the row_data_bound() here.
my code is below:
private void bind_gridview_with_dropdownlist()
{
SqlDataAdapter adp = new SqlDataAdapter("select UOM from Tbl_Com_Single where Flag='Bus'", con);
DataSet ds = new DataSet();
adp.Fill(ds, "Tbl_Com_Single");
bind_dropdownlist = (DropDownList)gvDetails.FooterRow.FindControl("DropftrTType");
bind_dropdownlist.DataSource = ds;
bind_dropdownlist.DataValueField = "UOM";
bind_dropdownlist.DataBind();
bind_dropdownlist.Items.Insert(0, new ListItem("Select", "Default value"));
}
its working fine in localhost and IIS also.
but when publishing it shows the following error:
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 303: DataSet ds = new DataSet();
Line 304: adp.Fill(ds, "Tbl_Com_Single");
Line 305: bind_dropdownlist = (DropDownList)gvDetails.FooterRow.FindControl("DropftrTType");
Line 306: bind_dropdownlist.DataSource = ds;
Line 307: bind_dropdownlist.DataValueField = "UOM";
Source File: c:\inetpub\vhosts\rktmithra.in\httpdocs\Bus\Entries.aspx.cs Line: 305
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Entries.bind_gridview_with_dropdownlist() in c:\inetpub\vhosts\rktmithra.in\httpdocs\Bus\Entries.aspx.cs:305
Entries.BindGridView() in c:\inetpub\vhosts\rktmithra.in\httpdocs\Bus\Entries.aspx.cs:319
Entries.Page_Load(Object sender, EventArgs e) in c:\inetpub\vhosts\rktmithra.in\httpdocs\Bus\Entries.aspx.cs:58
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +50
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627
getting error in 305 line
Please help me is possible to solve...
give me the solution..
thanks in advance
regards,
Raaj