S
Santosh
Hii i am writting a code for adding a user records but i want to
activate required filed validator before displaying conform addition
messagebox
i am writtng following code but it is never work please tell me that
what is solution behind them.
public void SetUpClientValidation(object sender, DataGridItemEventArgs
e)
{
if ( e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.SelectedItem )
{
e.Item.Cells[4].Attributes.Add("OnClick","JavaScript:return
ConfirmDeletionInformation();");
}
if(e.Item.ItemType == ListItemType.Footer)
{
e.Item.Cells[3].Attributes.Add("OnClick","JavaScript:return
ConformAddInformation();");
}
//
public void DataGridItemCommand(object sender, DataGridCommandEventArgs
e)
{
try
{
switch(e.CommandName)
{
case "GotoDistrict":
GoToDistrict(e.Item,e.Item.ItemIndex);
break;
case "AddNewRecords":
AddNewRecords(e.Item,e.Item.ItemIndex);
break;
}
}
catch(Exception ex)
{
ex.Message.ToString();
}
}
//
private void AddNewRecords(DataGridItem item, int rowIndex)
{
try
{
RequiredFieldValidator stateNoRequired
=(RequiredFieldValidator)item.FindControl("stateNo_Requiredfieldvalidator");
RequiredFieldValidator stateDescRequired
=(RequiredFieldValidator)item.FindControl("stateDesc_Requiredfieldvalidator");
RangeValidator stateNoRange =
(RangeValidator)item.FindControl("stateNo_RangeValidator");
stateNoRequired.Enabled = true;
stateDescRequired.Enabled = true;
stateNoRange.Enabled = true;
TextBox stateNo_TextBox =
(TextBox)item.FindControl("addStateNo_TextBox");
TextBox stateName_TextBox =
(TextBox)item.FindControl("addStateDesc_TextBox");
string recordFound =objStateMaster.FindRec(stateNo_TextBox.Text
,stateName_TextBox.Text);
if (recordFound!="")
{
string msg = " already exists" ;
string space = " and ";
string stateNo="StateNo: ";
string stateDesc= "StateName: ";
switch(recordFound)
{
case "11":
Response.Write("<script language=javascript> alert('"+ stateNo +
"' +'" + stateNo +"' + '"+ space +"' + '"+ stateDesc +"' + '"+
stateDesc +"'+ '" + msg + "');</script>");
break;
case "10":
Response.Write("<script language=javascript> alert('"+ stateNo
+"' +'" + stateNo +"' + '" + msg + "');</script>");
break;
case "01":
Response.Write("<script language=javascript> alert('"+ stateDesc
+"' +'"+ stateDesc + "' + '" + msg + "');</script>");
break;
}
return;
}
if(stateNo_TextBox != null)
{
objStateMaster.StateNo = stateNo_TextBox.Text;
}
if(stateName_TextBox != null)
{
objStateMaster.StateDesc = stateName_TextBox.Text;
}
objStateMaster.AddRec();
BindDataGrid();
stateNo_TextBox.Text="";
stateName_TextBox.Text="";
stateMaster_DataGrid.Columns[5].Visible = true;
}
catch(Exception ex)
{
ex.Message.ToString();
}
}
Regards,
Santosh Shinde
Vritti Software Solution.
activate required filed validator before displaying conform addition
messagebox
i am writtng following code but it is never work please tell me that
what is solution behind them.
public void SetUpClientValidation(object sender, DataGridItemEventArgs
e)
{
if ( e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.SelectedItem )
{
e.Item.Cells[4].Attributes.Add("OnClick","JavaScript:return
ConfirmDeletionInformation();");
}
if(e.Item.ItemType == ListItemType.Footer)
{
e.Item.Cells[3].Attributes.Add("OnClick","JavaScript:return
ConformAddInformation();");
}
//
public void DataGridItemCommand(object sender, DataGridCommandEventArgs
e)
{
try
{
switch(e.CommandName)
{
case "GotoDistrict":
GoToDistrict(e.Item,e.Item.ItemIndex);
break;
case "AddNewRecords":
AddNewRecords(e.Item,e.Item.ItemIndex);
break;
}
}
catch(Exception ex)
{
ex.Message.ToString();
}
}
//
private void AddNewRecords(DataGridItem item, int rowIndex)
{
try
{
RequiredFieldValidator stateNoRequired
=(RequiredFieldValidator)item.FindControl("stateNo_Requiredfieldvalidator");
RequiredFieldValidator stateDescRequired
=(RequiredFieldValidator)item.FindControl("stateDesc_Requiredfieldvalidator");
RangeValidator stateNoRange =
(RangeValidator)item.FindControl("stateNo_RangeValidator");
stateNoRequired.Enabled = true;
stateDescRequired.Enabled = true;
stateNoRange.Enabled = true;
TextBox stateNo_TextBox =
(TextBox)item.FindControl("addStateNo_TextBox");
TextBox stateName_TextBox =
(TextBox)item.FindControl("addStateDesc_TextBox");
string recordFound =objStateMaster.FindRec(stateNo_TextBox.Text
,stateName_TextBox.Text);
if (recordFound!="")
{
string msg = " already exists" ;
string space = " and ";
string stateNo="StateNo: ";
string stateDesc= "StateName: ";
switch(recordFound)
{
case "11":
Response.Write("<script language=javascript> alert('"+ stateNo +
"' +'" + stateNo +"' + '"+ space +"' + '"+ stateDesc +"' + '"+
stateDesc +"'+ '" + msg + "');</script>");
break;
case "10":
Response.Write("<script language=javascript> alert('"+ stateNo
+"' +'" + stateNo +"' + '" + msg + "');</script>");
break;
case "01":
Response.Write("<script language=javascript> alert('"+ stateDesc
+"' +'"+ stateDesc + "' + '" + msg + "');</script>");
break;
}
return;
}
if(stateNo_TextBox != null)
{
objStateMaster.StateNo = stateNo_TextBox.Text;
}
if(stateName_TextBox != null)
{
objStateMaster.StateDesc = stateName_TextBox.Text;
}
objStateMaster.AddRec();
BindDataGrid();
stateNo_TextBox.Text="";
stateName_TextBox.Text="";
stateMaster_DataGrid.Columns[5].Visible = true;
}
catch(Exception ex)
{
ex.Message.ToString();
}
}
Regards,
Santosh Shinde
Vritti Software Solution.