Sie sind auf Seite 1von 4

protected void grdData_RowEditing(object sender, GridViewEditEventArgs e) { grdData.EditIndex = e.NewEditIndex; LoadGrid(); } protected void grdData_RowCancelingEdit(object sender, GridViewCancelEdi tEventArgs e) { grdData.

EditIndex = -1; LoadGrid(); } protected void grdData_RowUpdating(object sender, GridViewUpdateEventArg s e) { try { string txtSlno = ((Label)grdData.Rows[e.RowIndex].FindControl("l blSlno")).Text; string txtDevId = ((TextBox)grdData.Rows[e.RowIndex].FindControl ("txtId")).Text; string txtSimNo = ((TextBox)grdData.Rows[e.RowIndex].FindControl ("txtSim")).Text; string txtSiteCode = ((TextBox)grdData.Rows[e.RowIndex].FindCont rol("txtSite")).Text; string txtDispBy = ((TextBox)grdData.Rows[e.RowIndex].FindContro l("txtDBy")).Text; string txtDispDate = ((TextBox)grdData.Rows[e.RowIndex].FindCont rol("txtDDate")).Text; string txtRecieveBy = ((TextBox)grdData.Rows[e.RowIndex].FindCon trol("txtRBy")).Text; string txtRecieveDate = ((TextBox)grdData.Rows[e.RowIndex].FindC ontrol("txtRDate")).Text; string txtCircle = ((TextBox)grdData.Rows[e.RowIndex].FindContro l("txtCircle")).Text; string txtDivision = ((TextBox)grdData.Rows[e.RowIndex].FindCont rol("txtDivision")).Text; string txtSubdiv = ((TextBox)grdData.Rows[e.RowIndex].FindContro l("txtSubDiv")).Text; string txtSection = ((TextBox)grdData.Rows[e.RowIndex].FindContr ol("txtSection")).Text; if (((DropDownList)grdData.Rows[e.RowIndex].FindControl("cmbStat us")).SelectedIndex == 0) { lblMsg.Text = "Select Status"; return; } string txtStatus = ((DropDownList)grdData.Rows[e.RowIndex].FindC ontrol("cmbStatus")).SelectedValue.ToString(); objsa.SampleSave(txtDispBy.Trim().ToUpper(), txtDispDate.Trim(), txtRecieveBy.Trim().ToUpper(), txtRecieveDate.Trim(), txtDevId.Trim(), txtSimNo .Trim(),txtCircle.Trim(),txtDivision.Trim(),txtSubdiv.Trim(),txtSection.Trim(), txtSiteCode.Trim(), txtStatus.Trim(), false,txtSlno.Trim()); lblMsg.Text = "Updated Details of Device Id='" + txtDevId + "' S uccessfully"; } catch (Exception ex) {

lblMsg.Text = ex.Message; } } protected void grdData_RowCommand(object sender, GridViewCommandEventArg s e) { if (e.CommandName.Equals("AddNew")) { string txtNewSlno = ((Label)grdData.FooterRow.FindControl("lblNe wSlno")).Text; string txtNewDevId = ((TextBox)grdData.FooterRow.FindControl("tx tNewId")).Text; string txtNewSimNo = ((TextBox)grdData.FooterRow.FindControl("tx tNewSim")).Text; string txtNewSiteCode = ((TextBox)grdData.FooterRow.FindControl( "txtNewSite")).Text; string txtNewDispBy = ((TextBox)grdData.FooterRow.FindControl("t xtNewDBy")).Text; string txtNewDispDate = ((TextBox)grdData.FooterRow.FindControl( "txtNewDDate")).Text; string txtNewRecieveBy = ((TextBox)grdData.FooterRow.FindControl ("txtNewRBy")).Text; string txtNewRecieveDate = ((TextBox)grdData.FooterRow.FindContr ol("txtNewRDate")).Text; string txtNewCircle = ((DropDownList)grdData.FooterRow.FindContr ol("cmbNewCircle")).SelectedValue.ToString(); string txtNewDiv = ((DropDownList)grdData.FooterRow.FindControl( "cmbNewDivision")).SelectedValue.ToString(); string txtNewSubDiv = ((DropDownList)grdData.FooterRow.FindContr ol("cmbNewSubDiv")).SelectedValue.ToString(); string txtNewsec = ((DropDownList)grdData.FooterRow.FindControl( "cmbNewSec")).SelectedValue.ToString(); if (((DropDownList)grdData.FooterRow.FindControl("cmbNewStatus") ).SelectedIndex == 0) { lblMsg.Text = "Select Status"; return; } string txtNewStatus = ((DropDownList)grdData.FooterRow.FindContr ol("cmbNewStatus")).SelectedValue.ToString(); objsa.SampleSave(txtNewDispBy.Trim().ToUpper(), txtNewDispDate.T rim(), txtNewRecieveBy.Trim().ToUpper(), txtNewRecieveDate.Trim(), txtNewDevId.T rim(), txtNewSimNo.Trim(), txtNewCircle.Trim(), txtNewDiv.Trim(), txtNewSubDiv.T rim(), txtNewsec.Trim(), txtNewSiteCode.Trim(), txtNewStatus.Trim(), true, txtNe wSlno.Trim()); lblMsg.Text = "Device Id '" + txtNewDevId + "' Saved Successfull y"; LoadGrid(); } } protected void grdData_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Footer) { General.Load_Combo("select CM_CIRCLE_CODE, CM_CIRCLE_NAME from T BLCIRCLE", "-SELECT-", (DropDownList)e.Row.FindControl("cmbNewCircle"));

} //if (e.Row.RowType == DataControlRowType.DataRow) // { // General.Load_Combo("select CM_CIRCLE_CODE, CM_CIRCLE_NAME fro m TBLCIRCLE", "-SELECT-", (DropDownList)e.Row.FindControl("cmbCircle")); // } } protected void cmbNewCircle_SelectedIndexChanged(object sender, EventArg s e) { DropDownList objdrop = (DropDownList)sender; GridViewRow row = (GridViewRow)objdrop.NamingContainer; if (objdrop.SelectedIndex > 0) { General.Load_Combo("SELECT DIV_CODE,DIV_NAME FROM TBLDIVISION WH ERE DIV_CICLE_CODE='" + objdrop.SelectedValue + "'", "-SELECT-", (DropDownList)r ow.FindControl("cmbNewDivision")); } else { ((DropDownList)row.FindControl("cmbNewCircle")).Items.Clear(); } } protected void cmbNewDivision_SelectedIndexChanged(object sender, EventA rgs e) { DropDownList objDiv = (DropDownList)sender; GridViewRow row = (GridViewRow)objDiv.NamingContainer; if (objDiv.SelectedIndex > 0) { General.Load_Combo("SELECT SD_SUBDIV_CODE,SD_SUBDIV_NAME FROM TB LSUBDIVMAST WHERE SD_DIV_CODE='" + objDiv.SelectedValue + "'", "-SELECT-", (Drop DownList)row.FindControl("cmbNewSubDiv")); } else { ((DropDownList)row.FindControl("cmbNewDivision")).Items.Clear(); } } protected void cmbNewSubDiv_SelectedIndexChanged(object sender, EventArg s e) { DropDownList objSubDiv = (DropDownList)sender; GridViewRow row = (GridViewRow)objSubDiv.NamingContainer; if (objSubDiv.SelectedIndex > 0) { General.Load_Combo("select OM_CODE,OM_NAME from TBLOMSECMAST whe re OM_SUBDIV_CODE='" + objSubDiv.SelectedValue + "'", "-SELECT-", (DropDownList) row.FindControl("cmbNewSec")); } else { ((DropDownList)row.FindControl("cmbNewSubDiv")).Items.Clear();

} } protected void cmbNewSec_SelectedIndexChanged(object sender, EventArgs e ) { DropDownList objSec = (DropDownList)sender; GridViewRow row = (GridViewRow)objSec.NamingContainer; ((TextBox)row.FindControl("txtNewSite")).Text=((DropDownList)row.Fin dControl("cmbNewSec")).SelectedValue.ToString(); }

Das könnte Ihnen auch gefallen