<dx:ASPxGridView
ID="gvSearchPTWNo" runat="server" Width="98%"
OnRowCommand="gvCertificate_ RowCommand"
KeyFieldName="ID">
<Columns>
<dx:GridViewDataColumn Caption="Asset Name" FieldName="AssetNames"
VisibleIndex="0">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Section Name"
FieldName="SectionNames" VisibleIndex="1">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="PTW No."
FieldName="CertNums" VisibleIndex="2">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Work Location"
FieldName="WorkLocation" VisibleIndex="3">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Select">
<DataItemTemplate>
<asp:LinkButton ID="lbtnSelect"
runat="server" Text="Select" CommandName="Select"
CommandArgument='<%#
Eval("CertID") %>'></asp:LinkButton>
</DataItemTemplate>
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Section ID"
FieldName="SectionID" Visible="false">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Asset ID"
FieldName="AssetID" Visible="false">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Asset ID"
FieldName="CertiStatus" Visible="false">
</dx:GridViewDataColumn>
<dx:GridViewDataColumn Caption="Cert Stage"
FieldName="CertStages" Visible="false">
</dx:GridViewDataColumn>
</Columns>
</dx:ASPxGridView>
protected
void gvCertificate_RowCommand( object sender,
DevExpress.Web.ASPxGridView. ASPxGridViewRowCommandEventArg s e)
{
string commandname = e.CommandArgs.CommandName;
int visibleIndex = Convert.ToInt32(e. VisibleIndex);
if (commandname == "Select")
{
var objVal = gvSearchPTWNo.GetRowValues( visibleIndex,
"CertNum");
var objVal1 = gvSearchPTWNo.GetRowValues( visibleIndex,
"SectionName");
var objVal2 = gvSearchPTWNo.GetRowValues( visibleIndex,
"AssetName");
var objSecId = gvSearchPTWNo.GetRowValues( visibleIndex,
"SectionID");
var objAssetId = gvSearchPTWNo.GetRowValues( visibleIndex,
"AssetID");
var objCertStatus = gvSearchPTWNo.GetRowValues( visibleIndex,
"CertStatus");
var objCertStage = gvSearchPTWNo.GetRowValues( visibleIndex,
"CertStage");
if (visibleIndex >= 0)
{
if (VisibleCertificate == 1)
{
TextBox txtParent = (TextBox)Parent.FindControl(" txtPTWno");
DropDownList ddlAsset_parent = (DropDownList)Parent. FindControl("ddlAsset");
UserControl.DeptSections ddlSections_parent = (UserControl.DeptSections) Parent.FindControl(" usercontrol_sections");
ddlSections_parent. bindSectionsAndDepts(Convert. ToInt32(objAssetId.ToString()) ,
Convert.ToInt32(objSecId. ToString()));
//UserControl.DeptSections ddlSections_parent;
TextBox txtSections = (TextBox)ddlSections_parent. FindControl("txtSections");
txtSections.Attributes.Add(" SectionId",
objSecId.ToString());
//txtSections.Text = objVal1.ToString();
ddlAsset_parent.Items. RemoveAt(0);
ddlAsset_parent.Items. FindByValue(objAssetId. ToString()).Selected = true;
txtParent.Text = objVal.ToString();
}
else
{
ASPxGridView grvCertificate_parentUctrl = (ASPxGridView)Parent. FindControl("gvCertificates");
grvCertificate_parentUctrl. DataSource =
GVCertificate(objVal.ToString( ),
objCertStatus.ToString(), objCertStage.ToString());
grvCertificate_parentUctrl. DataBind();
}
}
}
}
A primary key field specified via the KeyFieldName property is not found in the underlying data source. Make sure the field name is spelled correctly. Pay attention to the character case.
--For this issue we will set the KeyFieldName property in devexpress gridview,whatever we bind the data from database,we will check the field name perfectly...
No comments:
Post a Comment
Comments