This is a migrated thread and some comments may be shown as answers.

RadGrid, DataTable And Caption Problem

4 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
KlimUser
Top achievements
Rank 2
KlimUser asked on 29 Apr 2008, 11:47 PM
Well my problem is the next buddies
I have a GridView, well Actually a RagGrid From telerik control
I get the data executing a StoreProcedure and storing in a Datatable
the I just use the next code

DataTable dtListValues = null; //this is my DataTable where i'm going to store the Data
dtListValues = LoValues.oListValues(Values.PKValue); //this is the method to get the Data, that returns a DataTable
this.rgValues.DataSource = dtListValues; //Choosing  a DataSource for the RadGrid
this.rgValues.DataBind(); //binding!! hehehe!  ;P
and then the page ends with this

NameColumns     PKValue  NameValue  isActive

but!! I don't want to use this names!!  :sigh:
And to "fix" this I try to use this

dtListValues.Columns[0].Caption = "Code";
dtListValues.Columns[1].Caption = "Name";
dtListValues.Columns[2].Caption = "Active";
I already used this code after and before executing the DataBind
But!!!! It doesn't work!!! =(
Could someone Tell Me where I'm wrong :( ?
I hope you can help me please
thanks in advanced
Greetings!!!

4 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 30 Apr 2008, 04:28 AM
Hi,

Try setting the HeaderText for the GridColumns in the ItemDataBound event using the ColumnUniqueName property.

CS:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridHeaderItem) 
        { 
            GridHeaderItem header = (GridHeaderItem)e.Item; 
            string strtxt = header["columnUniqueName"].Text.ToString(); 
            if (strtxt == "PKValue  ") 
            { 
                header["columnUniqueName"].Text = "Code"
            } 
            
        } 
   } 


Thanks
Shinu.
0
KlimUser
Top achievements
Rank 2
answered on 21 May 2008, 03:52 PM
Hey Shinu!!
too Many Many many Thx!!!!
Your Help waas great!!
Rigth now The RadGrid Use the names I Want in Execution Time!!
too Much Tnks
And an apologize to answer until now but I was developing the rest of the pages and i left to the last this "issue" =)
Very Thankfully!!!
Greetings From Mexico!!!

0
Shinu
Top achievements
Rank 2
answered on 22 May 2008, 06:27 AM
Hi Friend,

I hope you will interested to go through the following help articles.

Accessing cells and rows
Using columns

Shinu.
0
KlimUser
Top achievements
Rank 2
answered on 30 Sep 2008, 10:45 PM
Thnks again Shinu!
I was reading the help =$ I think I should reading more berofe post =$
Now I'm even more thankful. =)
Gretings!!!

Tags
Grid
Asked by
KlimUser
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
KlimUser
Top achievements
Rank 2
Share this question
or