i want fill grid's first & second column query1, , third column query2, , fourth column query3.
the code run in rowdatabound
event of grid, it's not working:
protected void gvinner_rowdatabound(object sender, gridviewroweventargs e) { gvinner.visible = true; if (e.row.rowtype == datacontrolrowtype.datarow) { label iso = (label)gvinner.findcontrol("lbl_iso"); label description = (label)gvinner.findcontrol("lbl_desp"); string str1 = @"select m_mr_iso_heads.iso iso, m_mr_iso_heads.description description t_mr_action_point_pre_mrm_c inner join m_mr_iso_heads on t_mr_action_point_pre_mrm_c.iso_heads = m_mr_iso_heads.description"; datatable dt = new datatable(); dt = sql_db.executedatatable(str1); if (dt.rows.count > 0) { iso.text = dt.rows[0]["iso"].tostring(); description.text = dt.rows[0]["description"].tostring(); } label mrmpoints = (label)gvinner.findcontrol("lbl_mrmpoints"); string str2 = @"select t_mr_action_point_pre_mrm_c.mrm_no mrmpoints t_mr_action_point_pre_mrm_c inner join m_mr_iso_heads on t_mr_action_point_pre_mrm_c.iso_heads = m_mr_iso_heads.description , t_mr_action_point_pre_mrm_c.iso_heads = m_mr_iso_heads.description"; datatable dt1 = new datatable(); dt1 = sql_db.executedatatable(str2); if (dt1.rows.count > 0) { mrmpoints.text = dt1.rows[0]["mrmpoints"].tostring(); } label totalpoints = (label)gvinner.findcontrol("lbl_tpoints"); string str3 = @"select count(t_mr_action_point_pre_mrm_c.mrm_no) totalpoints t_mr_action_point_pre_mrm_c inner join m_mr_iso_heads on t_mr_action_point_pre_mrm_c.iso_heads = m_mr_iso_heads.description , t_mr_action_point_pre_mrm_c.iso_heads = m_mr_iso_heads.description"; datatable dt2 = new datatable(); dt2 = sql_db.executedatatable(str3); if (dt2.rows.count > 0) { totalpoints.text = dt2.rows[0]["totalpoints"].tostring(); } } }
change these lines.
label iso = (label)gvinner.findcontrol("lbl_iso"); label description = (label)gvinner.findcontrol("lbl_desp");
with
label iso = (label)e.row.findcontrol("lbl_iso"); label description = (label)e.row.findcontrol("lbl_desp");
Comments
Post a Comment