I'm filling a previously created DataGridView on an ASP.NET Web Form dynamically with a DataTable, but I want to change the name of the columns that appear on that DataGridView, and I simply can't figure out what I'm doing wrong. Below is the code:
DataTable dtUsuarios = DBManager.RunSqlGetDataTable(
@"select b.UserName, c.Email, c.IsLockedOut, c.LastLoginDate,
case
when e.RoleName is not null then 1
else 0 end Admin
from dbo.aspnet_Applications a join dbo.aspnet_Users b
on a.ApplicationId = b.ApplicationId
join dbo.aspnet_Membership c
on b.ApplicationId = c.ApplicationId
and b.UserId = c.UserId
left join dbo.aspnet_UsersInRoles d
on d.UserId = b.UserId
left join dbo.aspnet_Roles e
on d.RoleId = e.RoleId
where a.ApplicationName = 'Mont Blanc Catalogo'");
dtUsuarios.Columns["UserName"].Caption = "Nome Usuário";
dtUsuarios.Columns["Email"].Caption = "E-mail";
dtUsuarios.Columns["IsLockedOut"].Caption = "Bloqueado";
dtUsuarios.Columns["LastLoginDate"].Caption = "Último Login";
dtUsuarios.Columns["Admin"].Caption = "Administrador";
DataView dvUsuarios = new DataView(dtUsuarios) { Sort = "UserName" };
gdvUsuarios.DataSource = dvUsuarios;
gdvUsuarios.DataBind();
//gdvUsuarios.Columns[0].HeaderText = "Nome Usuário";
//gdvUsuarios.Columns[1].HeaderText = "E-mail";
//gdvUsuarios.Columns[2].HeaderText = "Bloqueado";
//gdvUsuarios.Columns[3].HeaderText = "Último Login";
//gdvUsuarios.Columns[4].HeaderText = "Administrador";
Setting the values changing the caption of the DataTable doesn't work, and after the DataBind, the Columns.Count property for the DataGridView return zero columns! After executing the code, everything appears normally at my asp page, but the captions are wrong.
My issue is that , need to change the column name(following some format) of the gridview (which is binded with XMLTextReader). Without changing directly XML file, Required to change the column name dynamically at runtime .
I have set up the itemstyle with and wrap to false, but anyways the width columns grows the the data is too long. i just want to change the height of the column not the width. Here us the complete code of the datagridview
I am trying to export my Model to an Excel sheet. I have 31 fields out of which only 29 are exported. Among the 3 fields that I am not able to export 2 are of type Enum and one of DateTime. Their is another DateTime field also, but that is exported properly. Here are few fields of the model :
[EnumDataType(typeof(Suffix)), Display(Name = "Suffix *")] [Required(ErrorMessage = "Suffix is Required")] public Suffix NameSuffix { get; set; } [EnumDataType(typeof(InquiryStatus)), Display(Name = "Status")] [Required(ErrorMessage = "Status is Required")]
[Code] ....
Among the 4 fields above, NameSuffix, Inquiry_Status & FollowUpDate are not exported. InquiryDate is exported.
I have a column in datagridview which is display the vendor services. It is a textbox type when display. However, when I want to edit the service. I would like to click on the cell, and the cell change to combobox for me to choose. How can I do that?
I am new to asp.net and was trying to use datagridview in my webform. I was able to bind it to my database but I cannot make the datagridview's buttonfield respond. It seems the grid's SelectedIndexChanged event is not being fired or has issues with postback. Even a very simple statement is not being executed by the program e.g.
Just wondering if anyone has ever managed to find a way to have a datagridview image button column in a template field which display different images on different rows depending on some data element in the row. Our application needs to display a series of fees charged against an account column which will be either less then 500, 500 to 1000 or >1000. Some of those fees are charged at a full rate, others at a partial rate, and some are not charged at all. The user would like to see a simple 3-state graphic which would convey the simple info: full-charge, partial-charge, or no-charge. Sounds easy enough but I've not yet managed to find a way to do this. Every time I attempt to modify the individual cell's graphic it seems to want to change the graphic for all the rows.
I Have to present This Data using DataGird on the bellow format
Employee Id Employee Name 01-01-2011 In Time Out Time Remarks 1 Mr Netra Thapa 09:01:59 18:0:15 Earlry In 2 Mr Luja Manadhar 10:15:00 17:0:15 Late In , Early Out 3 Mr Kushal Joshi Absent 4 Mr Prakash Gobhaju 09:00:15 18:30:15 Late Out
I have a rad grid, i have bounded the columns in the grid using GripBoundColumns which shows me dropdown cloumns when i edit the record, Insert/update/delete are working fine for me.
My question is it possible to insert new data into the column(Not the whole record just only to one column) when i edit the record.
For example...
suppose i have 5 columns (Client Name, Account No, Account name, account status, Custodian Dealer) CustodianDealer is my drop down coloumn and data for it comes from different table when i edit or insert a new record in the grid, i can select the existing Custodiandealers in the table.
now if i want to insert a new record to the custodianDealer table not to the grid, how can i acheive it
In my website1, I posted some data to my website2 by doing an HttpWebRequest.The data are posted successfully but what I wanna do is change the imageUrl in website2 after website1 fired some data. When I try to debug, I can see that it passes through the code of changing the ImageUrl, but when I view the source of website2, I can't see the imageUrl being change at all... Does anyone have a clue?
i m using embed tag for displaying video file.i want to change file in src attribute of embed tag runtime when i click on button.how can i access embed tag in my .cs file .
At runtime I would like to be able to change the ascx to another path, it would still be inheriting from the same usercontrol codebehind, it would just be a different template.
I have tabs in a page. Each tab has a background image of fixed length. So when the text for the tab is bigger("arrangement help"), it displays "arrangement" in one line and "help" underneath. My goal is to display arrangement and help in one line. Tabs have to customizable.I am using css for regular tabs.
#tabs a { float:left; background:url("../images/selection_deselect_bg.jpg") no-repeat right top; margin:0; text-decoration:none; width:105px; text-align:center; height:24px; font-size:12px; color:#00779c; font-weight:bold; text-decoration:none; }.
I have an bigger image and i am able to get the size of the text in tab. But how to use bigger image for the tab? How to use change background on runtime.
one of my client has the requirement of changing the latest news section of website dynamically or runtime so not to publish the site and host it agian and again.this section is in master page how can i achieve this in asp.net c#
Protected Sub gvCriticalMaterials_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles gvCriticalMaterials.RowCreated If e.Row.RowType = DataControlRowType.DataRow Then If Trim(e.Row.Cells(7).Text) <> "" And Trim(e.Row.Cells(10).Text) <> "" Then If Convert.ToDateTime(e.Row.Cells(7).Text) < Convert.ToDateTime(e.Row.Cells(10).Text) Then e.Row.Cells(7).ForeColor = Drawing.Color.Red End If End If End If End Sub
But it never shows any value for text in the cells.