Gridview Column options

Asked By Naresh Kumar
06-Sep-10 05:35 AM
Earn up to 0 extra points for answering this tough question.
Hi all,

Can I have the gridview in the below format.
HeaderColumn1 HeaderColumn2   HeaderColumn3  
Column Column Column
Column | Column Column | Column Column | Column
Row Row Row Row Row


In this I need to have subColumns in a column , can anyone please let me know how to accomplish this.

Thanks in advance.

  re: Gridview Column options

Anand Malli replied to Naresh Kumar
06-Sep-10 05:53 AM
Hi Naresh,

You can surely do it with <asp:template> columns,which provides and allows you to take any control inside gridview,so what you can do is under that column you can create html or asp table which will result in the output which you provided

let me know if anything is there
THANKS

  re: Gridview Column options

Naresh Kumar replied to Anand Malli
06-Sep-10 06:09 AM
Thanks for your reply,

Can you please send sample gridview with <asp:Template> columns, that would be better.

  re: Gridview Column options

Anand Malli replied to Naresh Kumar
06-Sep-10 06:25 AM
HI Naresh,

i have created one sample grid for you..it does not do anything but just to show you how you can create the layout of your choice by using template column,below is mark up for it

<asp:GridView ID="sampleGrid" runat="server" AutoGenerateColumns="True"
    CellPadding="4" ForeColor="#333333" GridLines="None">
    <RowStyle BackColor="#EFF3FB" />
    <Columns>
      <asp:TemplateField HeaderText="HeaderColumn1">
        <ItemTemplate>
          <label></label>
        </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="HeaderColumn2">
        <ItemTemplate>
          <table border="1" width="100%">
            <tr>
              <td>
                Col1
              </td>
            </tr>
            <tr>
              <td>
                Col2
              </td>
              <td>
                Col3
              </td>
            </tr>
          </table>
        </ItemTemplate>
      </asp:TemplateField>
      <asp:TemplateField HeaderText="HeaderColumn3">
        <ItemTemplate>
          <table border="1" width="100%">
            <tr>
              <td>
                Col1
              </td>
              <td>
                Col2
              </td>
               
            </tr>
          </table>
        </ItemTemplate>
      </asp:TemplateField>
    </Columns>
    <FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
    <EditRowStyle BackColor="#2461BF" />
    <AlternatingRowStyle BackColor="White" />
  </asp:GridView>

now you will write your DataBinder tag inside any of your control where you would like to display the value from db right,but here i am showing how its devided in column and formated..see snapshot


i think this is how you want right...

let me know
thxs
  re: Gridview Column options
Naresh Kumar replied to Anand Malli
06-Sep-10 06:58 AM
Thanks a lot for your help.

Have a look at this also,



Create New Account
photo albam how to create photo albam using asp.net Have a look at the following sample projects: • This article explains an ASP.NET application to view and share photos online. http: / / www.codeproject EasyThumbs.aspx • How to upload files to Web pages in ASP.NET? How to read an image from a database using ADO.NET and display it in a Web page? http: / / www.codeproject best one are these, just help your self http: / / weblogs.asp.net / bleroy / archive / 2005 / 09 / 08 / a-simple-asp-net-photo-album.aspx http: / / www.codedigest.com / Articles / ASPNET
about gridview Hello sir, my gridview looks like this- - < asp : GridView ID = "GrdUser" runat = "server" AutoGenerateColumns = "False" DataSourceID = "SqlDataSource1" ShowHeader = "False" Width = "1000px"> < Columns > < asp : BoundField DataField = "filedata" SortExpression = "filedata"> < / asp : BoundField asp : TemplateField > < ItemTemplate > < asp : RadioButton ID = "rb1" runat = "server" GroupName = "aaa" Text = ' <%# DataBinder.Eval(Container.DataItem, "opt1") %> ' / > < / ItemTemplate > < / asp : TemplateField > < asp : TemplateField > < ItemTemplate > < asp : RadioButton ID = "rb2" runat = "server" GroupName = "aaa" Text DataBinder.Eval(Container.DataItem, "opt2") %> ' / > < / ItemTemplate > < / asp : TemplateField > < asp : TemplateField > < ItemTemplate
data repeaters how do i access this particular column in the repeater row from code behind ? <asp:repeater. . . . < ItemTemplate > < tr > < td > < / td > < td > <% # DataBinder.Eval(Container.DataItem, "SN" )%> . < / td > . . . . . when the values are bound dont understand how to access it. thanks and put Text = ' <% # DataBinder.Eval(Container.DataItem, "SN" )%> ' for the Label's Text Attribute try the following article and it solves your answer. . . The ASP.NET Repeater is a basic container control that allows you to the page. It's a handy control, especially since most ASP.NET pages that display data need to repeat the same kinds need? Let's consider the most obvious solution first—the ASP.NET Repeater control. The Repeater control does exactly what its name
sending multiple parameters in hyperlink column (navigateurl) dynamically hi, i ahve a datagrid in which i am passing parameters from hyperlink column rightnow iam passing the hyperlink column value as parameter as (dynamically) HyperLinkColumn hypercolumn = new HyperLinkColumn (); hypercolumn aspx?Projectid = {0}" ; grid.Columns.Add(hypercolumn); / / Grid columns BoundColumn column = new BoundColumn (); column.DataField = "col2" ; column.HeaderText = "col2name" ; grid.Columns.Add(column); column = new BoundColumn (); column.DataField = "col3 ; column.HeaderText = "col3name" ; grid.Columns.Add(column); i want other 3
Slideshow Hi All, I am using the Ajax Slideshow from asp.net / ajax samples. . . . . the sample code is working fine. . . But i Portrait style picture"); return(slides); } < / script > &nbsp; &nbsp; < br / > < br / > < asp : Image ID = "Image1" runat = "server" Height = "316px" Width = "388px" / > < br / > < br / > < asp : Label ID = "lblImageDescription" runat = "server" / > < br / > < br / > < asp : Button ID = "Btn_Previous" runat = "server" Text = "Previous asp : Button ID = "Btn_Next" runat = "server" Text = "Next" Width = "64px" / > < br / > < br / > < asp : Button ID = "Btn_Play" runat = "server" Text = "Play" / > < br / > < cc1 : SlideShowExtender Portrait style picture" ); return (slides); } < / script> &nbsp; &nbsp;<br / > <br / > <asp:Image ID = "Image1" runat = "server" Height = "316px" Width = "388px" / > <br / > <br / > <asp:Label ID = "lblImageDescription" runat = "server" / > <br / > <br / > <asp:Button ID = "Btn_Previous" runat = "server" Text = "Previous" / > <asp:Button ID
view Hi, I am not able to sort the country column. please let me know how to achieve this. Regards, Amit an IComparer derived class, DataGridComparer , that sort s by each column in turn. The code is quite simple. Firstly I cast DataGridViewCellCollection rhs) { foreach ( Sort ColDefn colDefn in _ sort ed Column s) { int retval = Comparer.Default.Compare( lhs[colDefn.colNum].Value two rows are indistinguishable. return 0 ; } Anonymous delegate When a column is requested by the user to be sort ed, the code needs to determine if that column is already being sort ed. If it is then it is promoted to be the primary sort column (in basic user interface or order swapped if using the internal Int16 colNum; internal bool ascending; internal Sort ColDefn( int column Num, Sort Order sort Order) { colNum = Convert.ToInt16( column Num); ascending = ( sort Order ! = Sort Order.Descending); } } The column s that are currently sort ed are stored in a simple array: List< Sort ColDefn> _ sort ed Column s; When you come to find out if a supplied
Datagrid I have a datagrid that contains records. The first column is checkboxes. I will have a "SELECT ALL" checkbox. As All' check box, use document.getElementByTagName to get all the options, then check if they belong to the Datagrid and then HTML> <HEAD> <title> GlobalAdjustmentsLunchDelete< / title> <meta content = "Microsoft Visual Studio .NET 7.1" name = "GENERATOR"> <meta content = "Visual Basic .NET 7.1" name = "CODE_LANGUAGE"> <meta content = "JavaScript" name = "vs_defaultClientScript"> <meta width = "100%" border = "0"> <TR> <td align = "center" width = "100%"> <asp:datagrid id = "grdResults" runat = "server" Width = "600px" Font-Names = "Tahoma CellPadding = "1" PageSize = "1"> <HeaderStyle Font-Bold = "True"> < / HeaderStyle> <Columns> <asp:TemplateColumn> <HeaderTemplate> <input type = "checkbox" ID = "checkAll" runat = "server" onclick = "selectAll();" name = "checkAll" > SELECT ALL< / asp:CheckBox> < / HeaderTemplate> <ItemTemplate> <input type = "checkbox" runat = "server asp:CheckBox> < / ItemTemplate> < / asp:TemplateColumn> <asp:TemplateColumn> <HeaderTemplate> ID< / HeaderTemplate> <ItemTemplate> <asp:Label ID = "itmPunchtimeId" text
Datalist: Databinder.Eval and Container.Item I'm using a datalist that a business name from a database in a simple manner <%# DataBinder.Eval(Container.DataItem, "BusinessName", "{0}" %> How can I format this The first is to use the DataFormatString property in the column itself. In addition, you can use the NullDisplayText field to value is null. However, this will only give you limited options on formatting, especially if you're looking at an empty only I had to fill in the details of the Databinder string i.e. <%# evaluate(DataBinder.Eval(Container.DataItem, "VacancyName")) %> and then: protected string evaluate (object value) {. . . Sean, I'm using a datalist and still using ASP.Net 1.1 (failed to mention) Thanks! Create New Account