Click here to Skip to main content
11,799,282 members (70,565 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 10-Sep-12 23:02pm
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 OriginalGriff 493
1 CPallini 410
2 Richard MacCutchan 319
3 phil.o 244
4 Kornfeld Eliyahu Peter 230
0 OriginalGriff 2,475
1 Maciej Los 1,860
2 KrunalRohit 1,496
3 CPallini 1,465
4 Richard MacCutchan 1,149

Advertise | Privacy | Mobile
Web01 | 2.8.151002.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