Hi friends,
protected void submitbtn_Click(object sender, EventArgs e) { classmarkgrid.Columns.Clear(); comp.ACADAMICYEAR = acyeardropdown.SelectedItem.Text.ToString(); comp.MEDIUM = mediumdropdown.SelectedItem.Text.ToString(); string cname = classdropdown.SelectedItem.Text; string[] divide = cname.Split('-'); comp.CLASSNAME = divide[0].ToString(); comp.SECTIONNAME = Convert.ToChar(divide[1].Trim().ToString()); comp.EXAMNAMES = examdropdown.SelectedItem.Text; DataSet getmark = inter.getclassmark(comp); if (getmark.Tables.Count >0) { if (comp.EXAMNAMES == "Quartely Exam" || comp.EXAMNAMES == "Half yearly exam" || comp.EXAMNAMES == "Annual Exam") { DataTable bindtable = inter.bindtablesformarksingrid(getmark); } else { DataTable bindtable1 = inter.bindtablesformarkextergrid(getmark); classmarkgrid.DataSource = bindtable1; } classmarkgrid.DataBind(); } else { DataTable studentlist = inter.getstudentlistformark(comp); DataTable getsubjectforclass = inter.getsubjectlist(comp); DataTable gridback =mark.setgrid(studentlist, getsubjectforclass, comp); if (comp.EXAMNAMES == "Quartely Exam" || comp.EXAMNAMES == "Half yearly exam" || comp.EXAMNAMES == "Annual Exam") { for (int i = 0; i < gridback.Columns.Count; i++) { if (i >= 3) { TemplateField adtmep = new TemplateField(); adtmep.ShowHeader = true; adtmep.HeaderText = gridback.Columns[i].ColumnName; adtmep.ItemTemplate = new gridviewtemplatewithoutbind(DataControlRowType.DataRow, gridback.Columns[i].ColumnName, gridback.Columns[i].ColumnName, "TextBox"); classmarkgrid.Columns.Add(adtmep); continue; } TemplateField adtmep1 = new TemplateField(); adtmep1.ShowHeader = true; adtmep1.HeaderText = gridback.Columns[i].ColumnName; adtmep1.ItemTemplate = new gridviewtemplate(DataControlRowType.DataRow, gridback.Columns[i].ColumnName, gridback.Columns[i].ColumnName, "Label"); classmarkgrid.Columns.Add(adtmep1); } } else { for (int i = 0; i < gridback.Columns.Count; i++) { if (i >= 3) { TemplateField adtmep = new TemplateField(); adtmep.ShowHeader = true; adtmep.HeaderText = gridback.Columns[i].ColumnName; adtmep.ItemTemplate = new gridviewtemplatewithoutbind(DataControlRowType.DataRow, gridback.Columns[i].ColumnName, gridback.Columns[i].ColumnName, "TextBox"); classmarkgrid.Columns.Add(adtmep); continue; } TemplateField adtmep1 = new TemplateField(); adtmep1.ShowHeader = true; adtmep1.HeaderText = gridback.Columns[i].ColumnName; adtmep1.ItemTemplate = new gridviewtemplate(DataControlRowType.DataRow, gridback.Columns[i].ColumnName, gridback.Columns[i].ColumnName, "Label"); classmarkgrid.Columns.Add(adtmep1); } } classmarkgrid.DataSource = gridback; classmarkgrid.DataBind(); // ViewState["bindclassmark"] = gridback; Savebtn.Visible = true; Cancelbtn.Visible = true; } }
In this code classgridview rowdatabound event fires for the 'else' condition. its ok. but for' if' condition rowdatabound event not fired. what is the problem?