Solved

How to Get the layout in gridview asp.net, c#

Posted on 2012-04-12
4
379 Views
Last Modified: 2012-08-13
I have a gridview that displays the data. I have  a Language column. How to split the Language column into two. Please see the attachment. How to get the layout of Language in gridview?


Thanks
layout.doc
0
Comment
Question by:Saroj13
4 Comments
 
LVL 7

Expert Comment

by:Lalit Chandra
ID: 37840212
visit this :  
http://forums.asp.net/t/1322532.aspx/1

Hope this would help you!!
0
 

Author Comment

by:Saroj13
ID: 37840337
Hi,

My current gridview. Below is my code. Currently, I am having two columns: one for english and spanish. How to implement so that it will be similar to layout.
 <asp:GridView Width="100%"
                                            AllowPaging="False"
                                            ID="gvScript"                                           DataKeyNames="Script_ID" Font-Size="X-Small"    
                                         
                                            OnRowDataBound="ScriptsGridView_RowDataBound"
                                            AutoGenerateColumns="False"
                                            DataSourceID="scriptsSource"  
                                            AutoGenerateEditButton="False"
                                            runat="server" >
                                           
                                            <Columns>
                                                <asp:TemplateField HeaderText="ID" HeaderStyle-HorizontalAlign="Left" SortExpression="Script_ID" >
                                                  <ItemTemplate>
                                            <asp:HyperLink  ID="hlFullEditModeLink"  runat="server"  NavigateUrl='<%# "EditScrip1.aspx?Script_ID=" + Eval("Script_ID")%>'  Text = '<%# Eval("Script_ID")%>'  />
                                     
                                                  </ItemTemplate>

                                                </asp:TemplateField>
                                                <asp:TemplateField HeaderText="Title" ItemStyle-Width="300px" HeaderStyle-HorizontalAlign="Left" SortExpression="ScriptTitle">
                                                  <ItemTemplate>                                    
                                                   <%# Eval("ScriptTitle")%>
                                                  </ItemTemplate>
                                                                                              </asp:TemplateField>
                                                               
         
                                                  <asp:TemplateField HeaderText="English">
                                                   <ItemTemplate>
                                                    <img src='../images/<%# GetImageNameForEnglishText(Container.DataItem) %>' />
                                                 </ItemTemplate>
                                                 </asp:TemplateField>
                                               

                                                  <asp:TemplateField HeaderText="Spanish">
                                                 <ItemTemplate>
                                                   
                                                       <img src='../images/<%# GetImageNameForSpanishText(Container.DataItem) %>' />
                                                  </ItemTemplate>
                                                </asp:TemplateField>
                                                 
</asp:gridview>
0
 
LVL 12

Accepted Solution

by:
AshleyBryant earned 500 total points
ID: 37841057
Based on what you have provided and the link that Lalit-Chandra gave, you would need to do something like this in your rowdatabound event in the code-behind.

protected void ScriptsGridView_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.Header)
        {
            GridViewRow row = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Normal);
            TableCell cell1 = new TableCell();
            cell1.ColumnSpan = 2;
            row.Cells.Add(cell1);

            TableCell cell2 = new TableCell();
            cell2.ColumnSpan = 2;
            cell2.Text = "Language";
            row.Cells.Add(cell2);

            ScriptsGridView.Controls[0].Controls.AddAt(0, row);
        }
    }

Open in new window

0
 
LVL 2

Expert Comment

by:Codecaesar
ID: 37848124
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question