S
Santosh
Dear all
I am writting following code for binding data to the header template of
the datagrid on the button click event. but it gives me an error object
referance is not set to an item of object
can any one tell me how i can bind data to the header template of the
datagrid on button click event.
private void button1_Click(object sender, System.EventArgs e)
{
selectQuery();
}
private void selectQuery()
{
try
{
string strcondition="WHERE ";
if(checkDistrict_CheckBox.Checked ==true)
{
strcondition = strcondition + " DistrictMaster."+ " districtid = "
+ district_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim() + "' ";
}
if(checkSDO_CheckBox.Checked ==true)
{
if (strcondition.Length > 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition + "SDOMaster."+ " SDOId = " +
SDO_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim() +"'" ;
}
if(checkTaluka_CheckBox.Checked ==true)
{
if (strcondition.Length > 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition +"TalukaMaster."+ "TalukaId ="+
taluka_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim() +"'";
}
if(checkCircle_CheckBox.Checked ==true)
{
if (strcondition.Length > 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition +"CircleMaster."+ "CircleId ="+
circle_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim()+"'" ;
}
if(checkVillage_CheckBox.Checked ==true)
{
if (strcondition.Length > 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition + "VillageMaster."+ "VillageId ="+
village_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim()+"' " ;
}
DataView dv ;
dv =
VS.DAC.PDMO.GeneralDesMng.SearchSectionsLinesByDistrict(strcondition);
if (dv.Count > 0)
{
Label number_Label =
(Label)searchResult_DataGrid.FindControl("numHeader_Label");
number_Label.Text= dv[0]["NumUnit"].ToString();
Label capacity_Label =
(Label)searchResult_DataGrid.FindControl("capHeader_Label");
capacity_Label.Text =dv[0]["CapUnit"].ToString();
Label address_Label =
(Label)searchResult_DataGrid.FindControl("addrHeader_Label");
address_Label.Text=dv[0]["AddrUnit"].ToString();
}
searchResult_DataGrid.DataSource = dv;
searchResult_DataGrid.DataBind();
}
catch(Exception ex)
{
Response.Write("<script language=Javascript> alert('"+
ex.Message.ToString()+"') ;</script>");
}
}
I am writting following code for binding data to the header template of
the datagrid on the button click event. but it gives me an error object
referance is not set to an item of object
can any one tell me how i can bind data to the header template of the
datagrid on button click event.
private void button1_Click(object sender, System.EventArgs e)
{
selectQuery();
}
private void selectQuery()
{
try
{
string strcondition="WHERE ";
if(checkDistrict_CheckBox.Checked ==true)
{
strcondition = strcondition + " DistrictMaster."+ " districtid = "
+ district_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim() + "' ";
}
if(checkSDO_CheckBox.Checked ==true)
{
if (strcondition.Length > 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition + "SDOMaster."+ " SDOId = " +
SDO_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim() +"'" ;
}
if(checkTaluka_CheckBox.Checked ==true)
{
if (strcondition.Length > 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition +"TalukaMaster."+ "TalukaId ="+
taluka_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim() +"'";
}
if(checkCircle_CheckBox.Checked ==true)
{
if (strcondition.Length > 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition +"CircleMaster."+ "CircleId ="+
circle_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim()+"'" ;
}
if(checkVillage_CheckBox.Checked ==true)
{
if (strcondition.Length > 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition + "VillageMaster."+ "VillageId ="+
village_DropDownList.SelectedValue +" and " +"
SectionLineMaster.SectionLineDescription = '" +
resouce_TextBox.Text.Trim()+"' " ;
}
DataView dv ;
dv =
VS.DAC.PDMO.GeneralDesMng.SearchSectionsLinesByDistrict(strcondition);
if (dv.Count > 0)
{
Label number_Label =
(Label)searchResult_DataGrid.FindControl("numHeader_Label");
number_Label.Text= dv[0]["NumUnit"].ToString();
Label capacity_Label =
(Label)searchResult_DataGrid.FindControl("capHeader_Label");
capacity_Label.Text =dv[0]["CapUnit"].ToString();
Label address_Label =
(Label)searchResult_DataGrid.FindControl("addrHeader_Label");
address_Label.Text=dv[0]["AddrUnit"].ToString();
}
searchResult_DataGrid.DataSource = dv;
searchResult_DataGrid.DataBind();
}
catch(Exception ex)
{
Response.Write("<script language=Javascript> alert('"+
ex.Message.ToString()+"') ;</script>");
}
}