I need to check the name of the first column to this radgrid.
How is this possible ?
I actually tried
var gridID = $find("<%=RadgridDataAval.ClientID %>");
var x = gridID.get_masterTableView().getColumnByUniqueName("Error");
Error is the name of one of the columns of the grid. However, says it doesn't exist
Also, I don't know if we have examples that show how to fetch colulmn name of a particular column in the mastertableview on the client side.
10 Answers, 1 is accepted
I tried this on my end and it is working fine. Have you set the correct column UniqueName? I would suggest you send your aspx code.
Here is the code I tried.
Actually I create a data table on the server side .
DataTable ddt = new DataTable();
and then set the data source of my radgrid equals to this data table.
Then does it really set the unique name for the radgrid columns if i create my radgrid like this ?
Just wondering . I really don't do it the way you created columns
how do i get the name of all the columns of the radgrid on client side ? is there any way to do that ?
I guess you have set AutoGenerateColumns to true. If so the name of the column will be the Column UniqueName.
You can access all the columns in a Grid on the client side as shown below.
how do i get the name of all the columns of the radgrid in C#?
protected void RadGrid1_DataBound(object sender, EventArgs e)
// Here i am trying to access the column names of Radgrid for implement the Multiple column header.
var count= RadGrid1.Columns.Count;
//but the count value is always zero.
You can loop through the columns as shown below.
I have two table like Task and Task History, with different column names for key reference(taskID(primary key in Task) and taskhID(foreign key in Task History) i want to bind this two table to rad grid.
while binding if i use taskhID, then
protected void radgv_OnDetailTableDataBind(object sender, GridDetailTableDataBindEventArgs e)
GridDataItem dataitem = (GridDataItem)e.DetailTableView.ParentItem;
if (e.DetailTableView.Name == "TaskHistory")
string id = dataitem.GetDataKeyValue("taskhID").ToString(); //error: Object reference not set to an instance of an object
e.DetailTableView.DataSource = GetDataTable("SELECT * FROM TaskHistory where taskhID= '" + id + "'");
Becouse column "taskID" is not exit in Table TaskHistory.
Please tell me the solution.
Can you please verify that the taskhID field is included in the DataKeyNames of the corresponding table view?
Looking forward to your reply.
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.
Can you solved problem.
I have the same question.
this.RadGrid1.Columns.Count = 0
Try using the RenderColumns collection of the MasterTableView instance to traverse the grid columns:
I hope this will prove helpful. Feel free to give it a try and let me know if it works for you.