|
 |
|
|
 |
|
|
 |
|
|
 |
|
|
After i add new header row to gridview follow you guide code. i found that i have problem when use paging any ideas?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hello,
Sorry for late replay... Have you solved the problem? If it still persists, let me know.
Thanks! Rajendran Thiagarajan. Senior .Net Developer.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi Rajendran, Thank for reply, my problem is still exist. I try to find solution for it. If you have any idea please let me know. Thank you
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
I have a fixed header that loses it's "FIX" once I add the new row.
Can someone help me to "simply" (as if any of this is simple?!?) replace the header row with my newly "dynamically" created row.
Any help would be greatly greatly appreciated !!!
Thanks Dan
Kudos on the article -- very impressive@@
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi, it's working great, thanks a lot. But maybe you should add to your article that the function created neeeds to be assigned to the OnRowCreated-Event of the gridview.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
Instead of putting simple text, you have to put LinkButton control.
Something like this: LinkButton lb = new LinkButton(); lb.ID = "LinkButtonSortHeader1"; lb.Text = "Department"; lb.OnClickClient="__doPostBack('ctl00$Sort$LinkButtonSortHeader1',''); return false;"
//Add Department oTableCell.Controls.Add(lb); oTableCell.ColumnSpan = 2; oGridViewRow.Cells.Add(oTableCell);
Hope this would help you!
Thanks! Rajendran Thiagarajan.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Thanks, I did it the same way: Just one change:
LinkButton Ltitle = new LinkButton(); Ltitle.Text = "Project Title"; Ltitle.Click +=new EventHandler(LinkTitle_Click); titleCell.Width = 220; titleCell.Controls.Add(Ltitle);
//than just mapped it to GridView Sorting protected void LinkTitle_Click(object sender, EventArgs e) { //Default gridView Sorting function gridView_Sorting(this, new GridViewSortEventArgs("ProjectName", SortDirection.Ascending)); }
Amit
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Hi Thanks for your code but I would like to have a header with data form the database... How would you do that ???
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
You wrote 'department' and 'employee' but if I have a gridview which takes in params the state of the employee and in the header I want the state's name. ex:
SELECT * FROM employee WHERE statecode = params
---------------------------------------------------------------- | Header State Name (from database) | ---------------------------------------------------------------- Employee Name | Employee Mail | Employee tel. | ... | | | ----------------------------------------------------------------
Something like that, is that clear ?
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
That params mught be coming from a user unput, probably a dropdownlist. So instead of using "Department" for header text you can you someting like cboState.SelectedItem.Text
Noman Muhammad Aftab, Software Mechanic
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Your solution works fine.
The only change would really help if you have the pager activated for the top and bottom.
oGridView.Controls(0).Controls.AddAt(1, oGridViewRow)
Just changing this line would help and the header will not then float over the top of the Pager .
|
| Sign In·View Thread·PermaLink | 5.00/5 (1 vote) |
|
|
|
 |
|
|
 |
|
|
Thanks for nice article. This is what I've been looking for. However, I still have problem with header text alignment. No matter what I do, I get the text aligned left in IE. But in firefox, it is working just fine and shown in the center.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Thanks. I got it working now. It was the style sheet in CSS file which was overriding the setting.
Thanks for the great article.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |
|
|
' Unable to cast object of type 'System.Web.UI.WebControls.GridViewRow' to type 'System.Web.UI.WebControls.Table'. **This occured while trying to merge headers We are trying it out in asp.net.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
Cast is not possible, because gridviewrow represents ROW and Webcontrol.Table represents TABLE.
May I know what you are trying to do?
Thanks! Rajendran Thiagarajan.
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
If I wanted to start in the 2nd cell of the table object instead of the first. How would I do that?
|
| Sign In·View Thread·PermaLink | 2.00/5 (1 vote) |
|
|
|
 |
|
|
I didn't understand clearly that, what you are trying to do?
But as far as my understanding, you want to create object in second cell and leave the first cell as empty. To achieve this you have to create one empty cell and add it to Gridview row[Example: oGridViewRow.Cells.Add(oEmptyCell);] and you have to reduce one ColumnSpan value.
Sample Code:
if (e.Row.RowType == DataControlRowType.Header) { //Build custom header. GridView oGridView = (GridView)sender; GridViewRow oGridViewRow = new GridViewRow(0, 0, DataControlRowType.Header, DataControlRowState.Insert); //Empty Cell TableCell oEmptyCell = new TableCell(); oEmptyCell.Text = " "; oGridViewRow.Cells.Add(oEmptyCell);
TableCell oTableCell = new TableCell(); //Add Department oTableCell.Text = "Department"; oTableCell.ColumnSpan = 2; oGridViewRow.Cells.Add(oTableCell);
//Add Employee oTableCell = new TableCell(); oTableCell.Text = "Employee"; oTableCell.ColumnSpan = 2; oGridViewRow.Cells.Add(oTableCell); oGridView.Controls[0].Controls.AddAt(0, oGridViewRow); }
Thanks! Thiagarajan Rajendran .Net Developer
|
| Sign In·View Thread·PermaLink | |
|
|
|
 |
|
|
 |