Binding 2 Fields To GridBoundColumn

10 posts, 1 answers
  1. r00tsecurity
    r00tsecurity avatar
    14 posts
    Member since:
    Apr 2007

    Posted 07 Apr 2009 Link to this post


    Hi all,

    I wanna learn if it's possible to bind 2 database fields into 1 bound column ?

    forexample I wanna bind QUANTITY,SELECTED_UNIT fields to 1 column..

    <telerik:GridBoundColumn DataField='QUANTITY + SELECTED_UNIT' >

    thanx in advance for solutions
  2. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 07 Apr 2009 Link to this post

    Hello,

    A suggestion is to use a CalculatedColumn as shown below with which you casn combine two database fields:
    aspx:
    <telerik:GridCalculatedColumn DataFields="QUANTITY, SELECTED_UNIT" Expression="{0}+{1}"></telerik:GridCalculatedColumn> 

    Thanks
    Princy.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. r00tsecurity
    r00tsecurity avatar
    14 posts
    Member since:
    Apr 2007

    Posted 07 Apr 2009 Link to this post

    thanks Princy  that's exactly what I am lookin' for...
  5. r00tsecurity
    r00tsecurity avatar
    14 posts
    Member since:
    Apr 2007

    Posted 07 Apr 2009 Link to this post

    and lastly can we insert literal text between these two datafields like;


         <telerik:GridCalculatedColumn DataFields="QUANTITY, SELECTED_UNIT" Expression="{0}+'&nbsp;'+ {1}"></telerik:GridCalculatedColumn>

     or something like this?

        <telerik:GridCalculatedColumn DataFields="QUANTITY, SELECTED_UNIT" Expression="{0}+{1}" DatatFormatString="{0} space {1}" ></telerik:GridCalculatedColumn>


  6. Ram
    Ram avatar
    97 posts
    Member since:
    Jun 2011

    Posted 23 Jul 2011 Link to this post

    Hi Princy.
    I'm using radgrid.
    In one gridboundcolm I'm dispaying the duration as like 360 numeric numbers.
    I want to show that numer in hh:mm:sec format. like 00:06:00 how can I do it
    Please help me.
  7. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 25 Jul 2011 Link to this post

    Hello Ram,

    Try setting the DataFormatString as shown below.
    aspx:
    <telerik:GridBoundColumn UniqueName="BirthDate" HeaderText="BirthDate"
     DataField="BirthDate" DataFormatString="{0:hh:mm:tt}">
    </telerik:GridBoundColumn>

    Thanks,
    Princy.
  8. Ram
    Ram avatar
    97 posts
    Member since:
    Jun 2011

    Posted 25 Jul 2011 Link to this post

    Hi Princy thanks for ur reply.
    But its not working as I expected.
    Is show the  string as "hh:mm:tt:
    its not converting number to hh:mm:tt format.
    Cloud you help me please
  9. Shivanshu
    Shivanshu avatar
    4 posts
    Member since:
    Nov 2012

    Posted 07 Jan 2013 Link to this post

    Hi, What can i do if i need to bind data some more complex expression like :

    <chorus:GridBoundColumn DataField="<%= (ActiveFlag!=0)?true:false%>" 
    HeaderText="ActiveFlag" UniqueName="ActiveFlag" DataType="System.Boolean" >

  10. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 11 Jan 2013 Link to this post

    Hi,

    As far as I know, you cannot set the value in markup. One suggestion is that you can set the text from code as shown below.
    C#:
    protected void RadGrid2_ItemDataBound(object sender, GridItemEventArgs e)
    {
        if (e.Item is GridDataItem)
        {
            GridDataItem item = (GridDataItem)e.Item;
            if (item["Uniquename"].Text == "0")
            {
                 item["Uniquename"].Text="true";
            }
        }
    }

    Thanks,
    Princy
  11. Shivanshu
    Shivanshu avatar
    4 posts
    Member since:
    Nov 2012

    Posted 11 Jan 2013 Link to this post

    Hi Princy..Thanks for your help. However, I was was looking for inline mark-up solution like below which i got later. 


    <telerik:GridTemplateColumn HeaderText="ActiveFlag" DataType="System.Boolean">
       <ItemTemplate> 
          <asp:CheckBox ID="CheckBox2" runat="server" Checked='<%# ((int.Parse(Eval("ActiveFlag").ToString()) != 0) ? true : false)%>'  Enabled="false"/>
       </ItemTemplate>
    </telerik:GridTemplateColumn>
    
    
    
    
    It's working for me.
    anyway, Thank for your time . :)




Back to Top
UI for ASP.NET Ajax is Ready for VS 2017