brno792
brno792

Reputation: 6799

DevExpress GridViewBandColumn pass C# variable to the Caption

<dx:GridViewBandColumn Caption="My Title" >

Instead of hard coding "My Title", I want the caption to read as a string variable from my aspx.cs file. That variable will change over time, so the caption needs to update dynamically.

So for example:

//C#
String var = "My Title";

//ASPx
<dx:GridViewBandColumn Caption=var >

How do I do this?

I can't create a label in the GridViewBandColumn and pass the variable that way.

Upvotes: 0

Views: 1575

Answers (1)

Ali
Ali

Reputation: 2592

You can make a variable protected or public in your C# class file to allow it be visible for your .aspx page as below:

//C#

protected string myValue = "My Title";

and in your .aspx file you can read that value like this:

<dx:GridViewBandColumn Caption="<%: myValue %>" />


Apparently the DevExpress doesn't allow inline code on this control so I have to update the the code above to the following solution:

//aspx.cs

Grid.Columns["MyCol"].Caption = "my title";  

//.aspx

<dx:GridViewBandColumn Name="MyCol" Caption="" />



and the client side solution would be changing the caption using JQuery by its own caption name: //.aspx

<dx:GridViewBandColumn Caption="myValue" />

//jquery

$("td:contains('myValue')").text("My Title");

Upvotes: 1

Related Questions