Click here to Skip to main content
11,494,851 members (60,553 online)
Rate this: bad
Please Sign up or sign in to vote.
See more: ASP.NET CSS

I want to set position of button and textbox in the same gridview cell at different position in have used gridview control in which, in the gridview header row dynamically buttons and textboxes are generated.i want to set postion of textbox to valign=top and align=center and for button valign=bottom and align=right.provide soln.thanx
Posted 11-Sep-12 0:02am
pradiprenushe at 11-Sep-12 5:24am
How you are adding it dynamically? Can you show code?
Vijay Walunj,Navi mumbai at 11-Sep-12 5:45am
my code is

<pre lang="vb">Dim txtFilter As New TextBox

Dim lnkSortCol As New LinkButton</pre>
<pre lang="vb">lnkSortCol.Font.Underline = False

lnkSortCol.CssClass = "headerLnkBtn"
lnkSortCol.Text = ds1.Tables(0).Columns(j).ColumnName
lnkSortCol.ID = "lnkSortCol_" + j.ToString
lnkSortCol.ClientIDMode = UI.ClientIDMode.Static
lnkSortCol.Attributes.Add("onclick", "sort('" + lnkSortCol.ID + "','" + dataType + "');return false;")
grvCtrl.HeaderRow.Cells(0).Controls.AddAt(0, lnkSortCol)

txtFilter.ID = "txtFilter_" + j.ToString
txtFilter.ClientIDMode = UI.ClientIDMode.Static
txtFilter.AutoPostBack = False
txtFilter.ReadOnly = False
txtFilter.CssClass = "txtFilter"
txtFilter.Height = "8"</pre>
grvCtrl.HeaderRow.Cells(0).Controls.AddAt(1, txtFilter)

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Rather than adding control individually
add both control in HtmlTable. Add that HtmlTable in gridview.

//Create linkbutton & textbox object & assign property here
HtmlTable table1 = new HtmlTable();
            HtmlTableRow row = new HtmlTableRow();
            HtmlTableCell cell;
            for (int j = 1; j <= 2; j++)
                cell = new HtmlTableCell();
                if (j == 1)
                    cell.Controls.Add(lnkSortCol );
                    cell.VAlign = "Top";
                    cell.VAlign = "Bottom";
            grvCtrl.HeaderRow.Cells(0).Controls.AddAt(0, table1);
Vijay Walunj,Navi mumbai at 11-Sep-12 8:20am
thanku for rply.i want inform you that you miss on line of code
code is


Code works
pradiprenushe at 11-Sep-12 8:25am

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Dnyaneshwar@Pune 692
1 Sergey Alexandrovich Kryukov 354
2 CHill60 293
3 Sascha Lefèvre 255
4 Nakul Chaudhari 236
0 Sergey Alexandrovich Kryukov 10,297
1 OriginalGriff 8,821
2 Sascha Lefèvre 3,864
3 Maciej Los 3,412
4 Richard Deeming 2,500

Advertise | Privacy | Mobile
Web03 | 2.8.150520.1 | Last Updated 11 Sep 2012
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100