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

Databinding in ItemDataBound

18 Answers 162 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Murali
Top achievements
Rank 1
Murali asked on 03 Jun 2013, 10:48 AM
Hi,

I want to create a  telerik radgrid. But am stuck with the itemdatabound.

My current asp code is :

aspx code:



<asp:GridView ID="gvwUserList" runat="server" OnPageIndexChanging="gridView_PageIndexChanging" OnSorting="gridView_Sorting"
                                OnRowDataBound="testGrid_RowDataBound" CellPadding="4" ForeColor="#333333" Font-Size="Smaller" PageSize="12"
                                AllowPaging="True" GridLines="None" Width="900px" AutoGenerateColumns="false" ShowFooter="False" AllowSorting="True">
                                <AlternatingRowStyle BackColor="White" />
                                <Columns>
                                    <asp:TemplateField HeaderText="Select All" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left">
                                        <HeaderTemplate>
                                            <asp:CheckBox ID="chkHeader" runat="server" onclick="javascript:HeaderClick(this);" />
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="chkStatus" runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="User Name" HeaderStyle-HorizontalAlign="Left" SortExpression="customername" ItemStyle-HorizontalAlign="Left">
                                        <ItemTemplate>
                                            <asp:HyperLink ID="hlkCustomerName" runat="server" ForeColor="#666666"></asp:HyperLink>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="User ID" SortExpression="userid" ItemStyle-HorizontalAlign="Left" Visible="false">
                                        <ItemTemplate>
                                            <asp:Label ID="lblCustomerID" runat="server" ForeColor="Black" Visible="false"> </asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="User ID" HeaderStyle-HorizontalAlign="Left" SortExpression="email" ItemStyle-HorizontalAlign="Left">
                                        <ItemTemplate>
                                            <asp:Label ID="lblemailaddress" runat="server" ForeColor="Black"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Employment Type" HeaderStyle-HorizontalAlign="Left" SortExpression="employmenttype" ItemStyle-HorizontalAlign="Left">
                                        <ItemTemplate>
                                            <asp:Label ID="lblEmploymentType" runat="server" ForeColor="Black"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="City" HeaderStyle-HorizontalAlign="Left" SortExpression="city" ItemStyle-HorizontalAlign="Left" Visible="false">
                                        <ItemTemplate>
                                            <asp:Label ID="lblCity" runat="server" Visible="false" ForeColor="Black"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="State" HeaderStyle-HorizontalAlign="Left" SortExpression="value" ItemStyle-HorizontalAlign="Left">
                                        <ItemTemplate>
                                            <asp:Label ID="lblState" runat="server" ForeColor="Black"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Phone Number" SortExpression="phonenumber" ItemStyle-HorizontalAlign="Center">
                                        <ItemTemplate>
                                            <asp:Label ID="lblPhoneNumber" runat="server" ForeColor="Black"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Role Type" HeaderStyle-HorizontalAlign="Left" SortExpression="role" ItemStyle-HorizontalAlign="Left" Visible="false">
                                        <ItemTemplate>
                                            <asp:Label ID="lblRoleType" runat="server" ForeColor="Black" Visible="false"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Status" HeaderStyle-HorizontalAlign="Left" SortExpression="typedescription" ItemStyle-HorizontalAlign="Left" Visible="false">
                                        <ItemTemplate>
                                            <asp:Label ID="lblStatus" runat="server" ForeColor="Black" Visible="false"></asp:Label>
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                </Columns>
                                <EditRowStyle BackColor="Gray" />
                                <HeaderStyle BackColor="#A2A6AF" Font-Bold="True" ForeColor="#990000" />
                                <PagerStyle BackColor="#A2A6AF" ForeColor="White" HorizontalAlign="Center" />
                                <RowStyle BackColor="#e5e5e5" />
                                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                                <%--<SortedAscendingCellStyle BackColor="#F5F7FB" />
                    <SortedAscendingHeaderStyle BackColor="#6D95E1" />
                    <SortedDescendingCellStyle BackColor="#E9EBEF" />
                    <SortedDescendingHeaderStyle BackColor="#4870BE" />--%>
                            </asp:GridView>

******************************************************************************************************************************************************************

aspx.cs code :

protected void testGrid_RowDataBound(object sender, GridViewRowEventArgs e)
    {

        if (Request.QueryString.ToString().Contains("email"))
        {
            email = Request.QueryString["email"].ToString();
            roleid = Request.QueryString["roleid"].ToString();

            email = QueryStringModule.Decrypt(email);
            roleid = QueryStringModule.Decrypt(roleid);
        }


        if (e.Row.RowType == DataControlRowType.DataRow)
        {

            HyperLink userName = ((HyperLink)e.Row.FindControl("hlkCustomerName"));
            Label userId = ((Label)e.Row.FindControl("lblCustomerID"));
            Label emailaddress = ((Label)e.Row.FindControl("lblemailaddress"));
            Label employmenttype = ((Label)e.Row.FindControl("lblEmploymentType"));
            Label city = ((Label)e.Row.FindControl("lblCity"));
            Label state = ((Label)e.Row.FindControl("lblState"));
            Label phonenumber = ((Label)e.Row.FindControl("lblPhoneNumber"));
            Label roletype = ((Label)e.Row.FindControl("lblRoleType"));
            Label status = ((Label)e.Row.FindControl("lblStatus"));

            userName.Text = DataBinder.Eval(e.Row.DataItem, "customername").ToString();

            userId.Text = DataBinder.Eval(e.Row.DataItem, "userid").ToString();
            emailaddress.Text = DataBinder.Eval(e.Row.DataItem, "email").ToString();
            employmenttype.Text = DataBinder.Eval(e.Row.DataItem, "employmenttype").ToString();
            city.Text = DataBinder.Eval(e.Row.DataItem, "city").ToString();
            state.Text = DataBinder.Eval(e.Row.DataItem, "value").ToString();
            phonenumber.Text = DataBinder.Eval(e.Row.DataItem, "phonenumber").ToString();
            roletype.Text = DataBinder.Eval(e.Row.DataItem, "role").ToString();
            status.Text = DataBinder.Eval(e.Row.DataItem, "typedescription").ToString();

            string query = QueryStringModule.Encrypt(email);
            string query1 = string.Empty;
            if (roleid != string.Empty)
                query1 = QueryStringModule.Encrypt(roleid);
            else
                query1 = Request.QueryString["roleid"].ToString();
            string query2 = QueryStringModule.Encrypt(roletype.Text);
            string query3 = QueryStringModule.Encrypt(userId.Text);

            userName.NavigateUrl = Constants.RedirectPages.UserEntry + "?userid=" + query3 + "&roleid=" + query1 + "&email=" + query + "&userRole=" + query2;

        }
}


Here the problem is how to use the findcontrol method in itemdatabound based on my code.


Thank you in advance


18 Answers, 1 is accepted

Sort by
0
Accepted
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Jun 2013, 11:24 AM
Hello,

Please try with below code snippet.

protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
  {
      RadGrid1.DataSource = null; // assign your datasource here
  }
  protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
  {
      if (e.Item is GridDataItem)
      {
          GridDataItem item = e.Item as GridDataItem;
          HyperLink hlkCustomerName = item.FindControl("hlkCustomerName") as HyperLink;
          if (hlkCustomerName != null)
          {
              // Access your hyperlink control here
          }
      }
  }
<telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource"
      OnItemDataBound="RadGrid1_ItemDataBound">
      <MasterTableView>
          <Columns>
              <telerik:GridTemplateColumn>
                  <ItemTemplate>
                      <asp:HyperLink ID="hlkCustomerName" runat="server" ForeColor="#666666"></asp:HyperLink>
                  </ItemTemplate>
              </telerik:GridTemplateColumn>
          </Columns>
      </MasterTableView>
  </telerik:RadGrid>


Let me know if any concern.

Thanks,
Jayesh Goyani
0
Murali
Top achievements
Rank 1
answered on 03 Jun 2013, 12:46 PM
Hello Jayesh,


Thanks for your help.

I think am making some problem with thw below code. Can you correct that ? Especially with the DataBinder.Eval part.


    protected void RadGrid3_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            HyperLink hlkCustomerName = item.FindControl("hlkCustomerName") as HyperLink;
            Label userId = item.FindControl("lblCustomerID") as Label;
            Label emailaddress = item.FindControl("lblemailaddress") as Label;
            Label employmenttype = item.FindControl("lblEmploymentType") as Label;
            Label city = item.FindControl("lblCity") as Label;
            Label state = item.FindControl("lblState") as Label;
            Label phonenumber = item.FindControl("lblPhoneNumber") as Label;
            Label roletype = item.FindControl("lblRoleType")as Label;
            Label status = item.FindControl("lblStatus") as Label;

            hlkCustomerName.Text = DataBinder.Eval(e.Item.DataItem, "customerName").ToString();
            userId.Text = DataBinder.Eval(e.Item.DataItem, "userid").ToString();
            emailaddress.Text = DataBinder.Eval(e.Item.DataItem, "email").ToString();
            employmenttype.Text = DataBinder.Eval(e.Item.DataItem, "employmenttype").ToString();
            city.Text = DataBinder.Eval(e.Item.DataItem, "city").ToString();
            state.Text = DataBinder.Eval(e.Item.DataItem, "value").ToString();
            phonenumber.Text = DataBinder.Eval(e.Item.DataItem, "phonenumber").ToString();
            roletype.Text = DataBinder.Eval(e.Item.DataItem, "role").ToString();
            status.Text = DataBinder.Eval(e.Item.DataItem, "typedescription").ToString();
        }
    }


And the other thing is if i place the radgrid inside a tabstrip, then i will not able to access the radgrid from code behind. Whsy is that so ?


Thank you
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Jun 2013, 01:14 PM
Hello,

if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            DataRow dr = e.Item.DataItem as DataRow; //i have take DataRow only for example you have to use your assigned object
            if (dr != null)
            {
                HyperLink hlkCustomerName = item.FindControl("hlkCustomerName") as HyperLink;
                if (hlkCustomerName != null)
                {
                    hlkCustomerName.Text = dr["customerName"].ToString();
                }
            }
        }


Thanks,
Jayesh Goyani
0
Murali
Top achievements
Rank 1
answered on 03 Jun 2013, 01:15 PM
Once when the control comes to the 
hlkCustomerName.Text = DataBinder.Eval(e.Item.DataItem, "customerName").ToString();

from here it goes to the catch block.

Database part is successfull.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 03 Jun 2013, 01:20 PM
Hello,

you can Access in page methods and Click events by using below samples.

protected void Page_Init(object sender, EventArgs e)
   {
       RadGrid RadGrid1 = RadPageView1.FindControl("RadGrid1") as RadGrid;
       // Access your radgrid without viewstate
   }
   protected void Page_Load(object sender, EventArgs e)
   {
       RadGrid RadGrid1 = RadPageView1.FindControl("RadGrid1") as RadGrid;
       // Access your radgrid with viewstate
   }
   protected void Page_PreRender(object sender, EventArgs e)
   {
       RadGrid RadGrid1 = RadPageView1.FindControl("RadGrid1") as RadGrid;
       // Access your radgrid with viewstate
   }
<telerik:RadTabStrip ID="TabStrip1" runat="server" EnableDragToReorder="true" Skin="Office2010Silver"
        MultiPageID="RadMultiPag1" SelectedIndex="0">
        <Tabs>
            <telerik:RadTab Text="Microsoft">
            </telerik:RadTab>
            <telerik:RadTab Text="Amazon">
            </telerik:RadTab>
            <telerik:RadTab Text="CNN">
            </telerik:RadTab>
            <telerik:RadTab Text="Telerik">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="RadMultiPag1" runat="server" SelectedIndex="0">
        <telerik:RadPageView ID="RadPageView1" runat="server" Height="1300" Style="overflow: hidden">
            <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False">
                <MasterTableView>
                    <Columns>
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <asp:HyperLink ID="hlkCustomerName" runat="server" ForeColor="#666666"></asp:HyperLink>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadPageView>
        <telerik:RadPageView ID="RadPageView2" runat="server" Height="1300" Style="overflow: hidden">
            <img alt="amazon" src="Img/Amazon.png" />
        </telerik:RadPageView>
        <telerik:RadPageView ID="RadPageView3" runat="server" Height="1300" Style="overflow: hidden">
            <img alt="cnn" src="Img/CNN.png" />
        </telerik:RadPageView>
        <telerik:RadPageView ID="RadPageView4" runat="server" Height="1300" Style="overflow: hidden">
            <img alt="telerik" src="Img/Telerik.png" />
        </telerik:RadPageView>
    </telerik:RadMultiPage>


Thanks,
Jayesh Goyani
0
Murali
Top achievements
Rank 1
answered on 03 Jun 2013, 02:02 PM
Hello,

When i give this line 

HyperLink hlkCustomerName = e.Item.FindControl("hlkCustomerName") as HyperLink;

in rowbound it returns null value. 


Kindly suggest


Thank you
0
Jayesh Goyani
Top achievements
Rank 2
answered on 04 Jun 2013, 05:41 AM
Hello,

Please try with below code snippet.

<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
    </telerik:RadScriptManager>
    <telerik:RadTabStrip ID="TabStrip1" runat="server" EnableDragToReorder="true" Skin="Office2010Silver"
        MultiPageID="RadMultiPag1" SelectedIndex="0">
        <Tabs>
            <telerik:RadTab Text="Microsoft">
            </telerik:RadTab>
            <telerik:RadTab Text="Amazon">
            </telerik:RadTab>
            <telerik:RadTab Text="CNN">
            </telerik:RadTab>
            <telerik:RadTab Text="Telerik">
            </telerik:RadTab>
        </Tabs>
    </telerik:RadTabStrip>
    <telerik:RadMultiPage ID="RadMultiPag1" runat="server" SelectedIndex="0">
        <telerik:RadPageView ID="RadPageView1" runat="server" Height="1300" Style="overflow: hidden">
            <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" OnNeedDataSource="RadGrid1_NeedDataSource"
                OnItemDataBound="RadGrid1_ItemDataBound">
                <MasterTableView>
                    <Columns>
                        <telerik:GridBoundColumn DataField="ID" UniqueName="ID">
                        </telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <asp:HyperLink Text='<%# Eval("Name") %>' ID="hlkCustomerName" runat="server" ForeColor="#666666"></asp:HyperLink>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadPageView>
        <telerik:RadPageView ID="RadPageView2" runat="server" Height="1300" Style="overflow: hidden">
            <img alt="amazon" src="Img/Amazon.png" />
        </telerik:RadPageView>
        <telerik:RadPageView ID="RadPageView3" runat="server" Height="1300" Style="overflow: hidden">
            <img alt="cnn" src="Img/CNN.png" />
        </telerik:RadPageView>
        <telerik:RadPageView ID="RadPageView4" runat="server" Height="1300" Style="overflow: hidden">
            <img alt="telerik" src="Img/Telerik.png" />
        </telerik:RadPageView>
    </telerik:RadMultiPage>
protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        dynamic data = new[] {
            new { ID = 1, Name ="Name1"},
            new { ID = 2, Name = "Name2"},
            new { ID = 3, Name = "Name3"},
             new { ID = 4, Name = "Name4"},
            new { ID = 5, Name = "Name5"}
        };
 
        RadGrid1.DataSource = data;
    }
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            HyperLink hlkCustomerName = item.FindControl("hlkCustomerName") as HyperLink;
            if (hlkCustomerName != null)
            {
                // Access your hyperlink control here
            }
        }
    }

Let me know if any concern.

Thanks,
Jayesh Goyani
0
Murali
Top achievements
Rank 1
answered on 04 Jun 2013, 09:33 AM
Hello,

When i give this line 

HyperLink hlkCustomerName = e.Item.FindControl("hlkCustomerName") as HyperLink;

hlkCustomerName  return null value...



Kindly suggest


Thank you
0
Jayesh Goyani
Top achievements
Rank 2
answered on 04 Jun 2013, 12:50 PM
Hello,

Can you please provide your code?

Thanks,
Jayesh Goyani
0
Murali
Top achievements
Rank 1
answered on 04 Jun 2013, 01:30 PM
Hello,

Here is my code

<telerik:RadGrid ID="RadGrid3" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid3_NeedDataSource" OnItemDataBound="RadGrid3_ItemDataBound">
                    <MasterTableView>
                        <Columns>
                            <telerik:GridTemplateColumn>
                                <ItemTemplate>
                                    <asp:HyperLink ID="hlkCustomerName" runat="server" ForeColor="#666666"></asp:HyperLink>
                                </ItemTemplate>
                                <ItemTemplate>
                                    <asp:Label ID="lblCustomerID" runat="server" ForeColor="Black" Visible="false"> </asp:Label>
                                </ItemTemplate>
                                <ItemTemplate>
                                     <asp:Label ID="lblemailaddress" runat="server" ForeColor="Black"></asp:Label>
                                </ItemTemplate>                         
                                <ItemTemplate>
                                     <asp:Label ID="Label1" runat="server" ForeColor="Black"></asp:Label>
                                </ItemTemplate>                                  
                                <ItemTemplate>
                                      <asp:Label ID="lblCity" runat="server" Visible="false" ForeColor="Black"></asp:Label>
                                </ItemTemplate>                                    
                                <ItemTemplate>
                                      <asp:Label ID="lblState" runat="server" ForeColor="Black"></asp:Label>
                                </ItemTemplate>                                    
                                <ItemTemplate>
                                      <asp:Label ID="lblPhoneNumber" runat="server" ForeColor="Black"></asp:Label>
                                </ItemTemplate>                                   
                                <ItemTemplate>
                                      <asp:Label ID="lblRoleType" runat="server" ForeColor="Black" Visible="false"></asp:Label>
                                </ItemTemplate>                                   
                                <ItemTemplate>
                                      <asp:Label ID="Label2" runat="server" ForeColor="Black" Visible="false"></asp:Label>
                                </ItemTemplate>                                    
                            </telerik:GridTemplateColumn>
                        </Columns>
                    </MasterTableView>
                </telerik:RadGrid>

****************************************************************************************************************************************
protected void Page_Load(object sender, EventArgs e)
    {
if (!IsPostBack)
            {
UserListing UserListingBO = new UserListing();
                DataSet UserListingDS = new DataSet();

  UserListingDS = UserListingBO.userlistDS();

                        if (UserListingDS.Tables.Count > 0)
                        {
                            if (UserListingDS.Tables[0].Rows.Count > 0)
                            {                           
                               RadGrid3.DataSource = UserListingDS;
                                RadGrid3.DataBind();
                                lblZeroRecordFound.Visible = false;
                            }
}
     }

***************************

protected void RadGrid3_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
    {
        //RadGrid3.DataSource = null;
        
    }

    protected void RadGrid3_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            
            //DataRow dr = e.Item.DataItem as DataRow;
            //if (dr!=null)
            //{
                //HyperLink hlkCustomerName = e.Item.FindControl("hlkCustomerName") as HyperLink;
                HyperLink hlkCustomerName = item.FindControl("hlkCustomerName") as HyperLink;
                Label userId = item.FindControl("lblCustomerID") as Label;
                Label emailaddress = item.FindControl("lblemailaddress") as Label;
                Label employmenttype = item.FindControl("lblEmploymentType") as Label;
                Label city = item.FindControl("lblCity") as Label;
                Label state = item.FindControl("lblState") as Label;
                Label phonenumber = item.FindControl("lblPhoneNumber") as Label;
                Label roletype = item.FindControl("lblRoleType") as Label;
                Label status = item.FindControl("lblStatus") as Label;
                if (hlkCustomerName != null)
                {
                   // hlkCustomerName.Text = dr["customername"].ToString();
                }
                //userId.Text = dr["userid"].ToString();
                //emailaddress.Text = dr["email"].ToString();
                //employmenttype.Text = dr["employmenttype"].ToString();
                //city.Text = dr["city"].ToString();
                //state.Text = dr["value"].ToString();
                //phonenumber.Text = dr["phonenumber"].ToString();
                //roletype.Text = dr["role"].ToString();
                //status.Text = dr["typedescription"].ToString();
            //}
        }
    }

I have been struggling with this for past two days. Help me please.
0
Jayesh Goyani
Top achievements
Rank 2
answered on 04 Jun 2013, 05:44 PM
Hello,

Please try with the below code snippet.

<telerik:RadGrid ID="RadGrid3" runat="server" AutoGenerateColumns="false" OnNeedDataSource="RadGrid3_NeedDataSource"
           OnItemDataBound="RadGrid3_ItemDataBound">
           <MasterTableView>
               <Columns>
                   <telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:HyperLink ID="hlkCustomerName" runat="server" ForeColor="#666666"></asp:HyperLink>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:Label ID="lblCustomerID" runat="server" ForeColor="Black" Visible="false"> </asp:Label>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:Label ID="lblemailaddress" runat="server" ForeColor="Black"></asp:Label>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:Label ID="Label1" runat="server" ForeColor="Black"></asp:Label>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:Label ID="lblCity" runat="server" Visible="false" ForeColor="Black"></asp:Label>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:Label ID="lblState" runat="server" ForeColor="Black"></asp:Label>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:Label ID="lblPhoneNumber" runat="server" ForeColor="Black"></asp:Label>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:Label ID="lblRoleType" runat="server" ForeColor="Black" Visible="false"></asp:Label>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
                   <telerik:GridTemplateColumn>
                       <ItemTemplate>
                           <asp:Label ID="Label2" runat="server" ForeColor="Black" Visible="false"></asp:Label>
                       </ItemTemplate>
                   </telerik:GridTemplateColumn>
               </Columns>
           </MasterTableView>
       </telerik:RadGrid>

Note : You can not take more then one ItemTemplate in One GridTemplateColumn.

Thanks,
Jayesh Goyani
0
Murali
Top achievements
Rank 1
answered on 05 Jun 2013, 10:03 AM
Hello,

Thank you jayesh, it's working fine now. I'll try to keep this grid inside a tabstrip. 
0
Murali
Top achievements
Rank 1
answered on 06 Jun 2013, 05:11 AM
Hi Jayesh,


Am using the bulit-in skin for radgrid. But its not working. i have set 
EnableEmbeddedSkins=true
skin=Glow.

kindly suggest

thank you
0
Shinu
Top achievements
Rank 1
answered on 06 Jun 2013, 05:28 AM
Hi Murali,

The skin 'Glow' has been added Since Q1 2013 release. Please make sure that you are using that version. Please check this help documentation

Thanks,
Shinu.
0
Murali
Top achievements
Rank 1
answered on 06 Jun 2013, 05:56 AM
Hi,

Yes am using the Q1 2013 release.
0
Murali
Top achievements
Rank 1
answered on 06 Jun 2013, 06:06 AM
Hi,

Its working now. I just removed the reference from bin and added it again.

Thank you
0
Murali
Top achievements
Rank 1
answered on 10 Jun 2013, 10:54 AM
Hi,

Am doing sorting in radgrid. Usually i will be doing like

sortedView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);
Gridview1.Datasource=sortedView;
gridview1.DataBind();


private string ConvertSortDirectionToSql(SortDirection sortDirection)
    {
        string newSortDirection = String.Empty;

        switch (sortDirection)
        {
            case SortDirection.Ascending:
                newSortDirection = "ASC";
                break;

            case SortDirection.Descending:
                newSortDirection = "DESC";
                break;
        }

        return newSortDirection;
    }

How do i achieve this is in Radgrid ?

Kindly suggest 

Thank you
0
Shinu
Top achievements
Rank 1
answered on 10 Jun 2013, 11:13 AM
Hi,

Please check this help documentation which describe about custom Custom Sort Criteria.

Thanks,
Shinu.
Tags
Grid
Asked by
Murali
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Murali
Top achievements
Rank 1
Shinu
Top achievements
Rank 1
Share this question
or