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(o bject sender, System.EventArg s e)
{
selectQuery();
}
private void selectQuery()
{
try
{
string strcondition="W HERE ";
if(checkDistric t_CheckBox.Chec ked ==true)
{
strcondition = strcondition + " DistrictMaster. "+ " districtid = "
+ district_DropDo wnList.Selected Value +" and " +"
SectionLineMast er.SectionLineD escription = '" +
resouce_TextBox .Text.Trim() + "' ";
}
if(checkSDO_Che ckBox.Checked ==true)
{
if (strcondition.L ength 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition + "SDOMaster. "+ " SDOId = " +
SDO_DropDownLis t.SelectedValue +" and " +"
SectionLineMast er.SectionLineD escription = '" +
resouce_TextBox .Text.Trim() +"'" ;
}
if(checkTaluka_ CheckBox.Checke d ==true)
{
if (strcondition.L ength 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition +"TalukaMaster. "+ "TalukaId ="+
taluka_DropDown List.SelectedVa lue +" and " +"
SectionLineMast er.SectionLineD escription = '" +
resouce_TextBox .Text.Trim() +"'";
}
if(checkCircle_ CheckBox.Checke d ==true)
{
if (strcondition.L ength 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition +"CircleMaster. "+ "CircleId ="+
circle_DropDown List.SelectedVa lue +" and " +"
SectionLineMast er.SectionLineD escription = '" +
resouce_TextBox .Text.Trim()+"' " ;
}
if(checkVillage _CheckBox.Check ed ==true)
{
if (strcondition.L ength 6)
{
strcondition = strcondition + " AND " ;
}
strcondition = strcondition + "VillageMaster. "+ "VillageId ="+
village_DropDow nList.SelectedV alue +" and " +"
SectionLineMast er.SectionLineD escription = '" +
resouce_TextBox .Text.Trim()+"' " ;
}
DataView dv ;
dv =
VS.DAC.PDMO.Gen eralDesMng.Sear chSectionsLines ByDistrict(strc ondition);
if (dv.Count 0)
{
Label number_Label =
(Label)searchRe sult_DataGrid.F indControl("num Header_Label");
number_Label.Te xt= dv[0]["NumUnit"].ToString();
Label capacity_Label =
(Label)searchRe sult_DataGrid.F indControl("cap Header_Label");
capacity_Label. Text =dv[0]["CapUnit"].ToString();
Label address_Label =
(Label)searchRe sult_DataGrid.F indControl("add rHeader_Label") ;
address_Label.T ext=dv[0]["AddrUnit"].ToString();
}
searchResult_Da taGrid.DataSour ce = dv;
searchResult_Da taGrid.DataBind ();
}
catch(Exception ex)
{
Response.Write( "<script language=Javasc riptalert('"+
ex.Message.ToSt ring()+"') ;</script>");
}
}