Solved

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

Posted on 2012-04-12
4
372 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
This video discusses moving either the default database or any database to a new volume.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now