Hello!
I have built a grid report with edit and insert feature. so far everything is fine except for validation which I will do it next and the problem I face below:
I have two fileds --SID and Username ( we are not talking about database design problem here) which are related. so one sid to one username ( unique).
I have hidden sid and username in Edit form and use ForceExtractValue="InEditMode" which works in insert and edit. I used codebehind to hide them in edit mode and show them in insert mode.
Now I want to when user input anything in sid or username field the other field is field with right data.
Or I want to hide sid and only show username in Insert mode. when user input username and I will get sid from database and add the value into the sid insert parameter then do insert.
How could I accomplish this.
I have built a grid report with edit and insert feature. so far everything is fine except for validation which I will do it next and the problem I face below:
I have two fileds --SID and Username ( we are not talking about database design problem here) which are related. so one sid to one username ( unique).
I have hidden sid and username in Edit form and use ForceExtractValue="InEditMode" which works in insert and edit. I used codebehind to hide them in edit mode and show them in insert mode.
protected void RadGrid3_ItemCommand(object source, GridCommandEventArgs e) |
{ |
///I have to hide the fields SID and Username in the edit mode but show them in the insert mode /// |
RadGrid grid = (source as RadGrid); |
if (e.CommandName == RadGrid.InitInsertCommandName) |
{ |
grid.MasterTableView.ClearEditItems(); |
RadGrid3.MasterTableView.GetColumn("SID").EditFormHeaderTextFormat = "SID:"; |
RadGrid3.MasterTableView.GetColumn("Username").EditFormHeaderTextFormat = "Username:"; |
} |
if (e.CommandName == RadGrid.EditCommandName) |
{ |
e.Item.OwnerTableView.IsItemInserted = false; |
RadGrid3.MasterTableView.GetColumn("SID").EditFormHeaderTextFormat = ""; |
RadGrid3.MasterTableView.GetColumn("Username").EditFormHeaderTextFormat = ""; |
} |
///show export |
if (e.CommandName == Telerik.Web.UI.RadGrid.ExportToExcelCommandName || |
e.CommandName == Telerik.Web.UI.RadGrid.ExportToWordCommandName || |
e.CommandName == Telerik.Web.UI.RadGrid.ExportToCsvCommandName || |
e.CommandName == Telerik.Web.UI.RadGrid.ExportToPdfCommandName) |
{ |
ConfigureExport(); |
} |
} |
protected void RadGrid3_ItemDataBound(object sender, GridItemEventArgs e) |
{ |
// update form |
if (e.Item is GridEditFormItem && e.Item.IsInEditMode && e.Item.OwnerTableView.IsItemInserted == false) |
{ |
GridEditFormItem editFormItem = (GridEditFormItem)e.Item; |
editFormItem["SID"].Visible = false; |
editFormItem["Username"].Visible = false; |
} |
// insert |
else if (e.Item is GridEditFormInsertItem && e.Item.IsInEditMode && e.Item.OwnerTableView.IsItemInserted == true) |
{ |
RadGrid3.MasterTableView.ClearEditItems(); |
} |
} |
Now I want to when user input anything in sid or username field the other field is field with right data.
Or I want to hide sid and only show username in Insert mode. when user input username and I will get sid from database and add the value into the sid insert parameter then do insert.
How could I accomplish this.