• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1284
  • Last Modified:

AspxGridView reset the filelds at runtime

I am using DevExpress Gridview bound to a SqlDataSource. At run time based on a field 'SchoolType' whose possible values are N or D; I want to change N to Non-Denom and D to Denom. I have tried the following the code to find the value but I can't figure out how to set or display the value as Denom or Non-Denom? Any ideas? Thanks

 protected void gvSchools_HtmlRowCreated(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewTableRowEventArgs e)
        {
            if (e.RowType != DevExpress.Web.ASPxGridView.GridViewRowType.Data) return;
            string str = (string)gvSchools.GetRowValues(e.VisibleIndex, "SchoolType");

            if (str == "N")
            {
// how to set the value?
         
            }

        }
0
mmalik15
Asked:
mmalik15
  • 5
  • 2
1 Solution
 
_Katka_Commented:
Hi, you have to hook the view event, CustomCellDisplayText() you should get e.Value in the args, and set e.DisplayText.


regards,
Kate
0
 
_Katka_Commented:
Little correction it is CustomColumnDisplayText event.

regards,
Kate
0
 
_Katka_Commented:
Here is the sample code:

1) hook the event on your form

gvSchools.CustomColumnDisplayText += gvSchools_CustomColumnDisplayText;

protected void gvSchools_CustomColumnDisplayText(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewColumnDisplayTextEventArgs e)
{
  if (e.Column.FieldName != "SchoolType") return;
 
  switch (e.Value.ToString())
  {
    case "D":
      e.DisplayText = "Denom";
      break;

    case "N":
      e.DisplayText = "Non-Denom";
      break;

    default:
      throw new NotSupportedException();
  }
}

regards,
Kate
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
mmalik15Author Commented:
Thanks so much!
0
 
_Katka_Commented:
You're welcome :)

regards,
Kate
0
 
_Katka_Commented:
One note, checkout the DevExpress support forum, you'll find all your answers there

http://www.devexpress.com/Support/Center/

Choose product group: ASP.NET
And your product: like ASPxGridView and Editors Suite

I'm developing with DevExpress for 8+ years, but I'm there daily. A new problem every day. :)

regards,
Kate
0
 
mmalik15Author Commented:
Thanks again :) Will try that in future :))
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 5
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now