SQL Server :: Dynamic Nullable Columns Depending On The Value Of A Column?
Feb 11, 2011
I have a master document which is composed of other document types (some are required and some are not). While the master document's status is "Draft" I need to ignore all not nullable constraints (because the writer may decide to work on one of the children
documents that is not required and save as draft).
The closest solution I found for this problem is check constraints but I have not yet to see an example of this in check contraint and I'm not even sure if this is possible. Has anyone implemented a similar solution with check constraints (or any other methods)?
i have a gridview which is populated from a stores proc using pivot tables. The column are created dynamically apart from a total column which is created as a template field. the gridview looks like below:
CPW EE Foh H3G IND O2 ORG P4U T-M TSC VIR VOD Total
Stores Visited
70 0 0 12 0 16 18 7 11 1 2 8 145
i need to add a hyperlink to each gridview cell and when that cell is clicked pass the header text through the querystring to another page. I can access the cells value ok and pass that through but i cannot seem to access the cells column header text. when i response.write out a count of the gridview.columns it brings back 2 which is the template fields but not the dynamic fields i have tried this on the rowdatbound, rowcreated, page_load and page_unload. the count should be 12 its like it cannot find the dynamic columns at all. ?
here is my code for populating the gridview
[Code]....
and here is my gridview:
[Code]....
i am also moving the total column in this code
[Code]....
and calculating my total in this code and adding my link to the total colum (which works fine)
[Code]....
now i just need to somehow add a link to the other cells and somehow get the value of the header text for that cell clicked.
Can anyone reliably get the EDS to save a nullable column to the databse as a "null" when bound to any of the controls such as "FormView"?I have tried using several different UpdateParameters (Session, ControlParamater, Parameter, etc). I have tried setting "ConvertEmptyStringToNull" to true and leaving the property off entirely. Nothing works. On my "Inserts" it works fine.(I have made sure the column is set to nullable = true in the Entity Designer.....)
I have to change the username column in my database to nullable, which means everywhere in my code, I now have to check username.HasValue and change references to username to username.Value. Is there anything I can do to avoid having to change all the references to username to username.Value?
Am I going to be able to query (using LINQ to SQL) a database field with a type like the following "public System.Nullable<System.DateTime> Spouse_DOB"?
I'm trying to use the following code: [Code]....
and I get the error "'System.Nullable<System.DateTime>' does not contain a definition for 'Month' and no extension method 'Month' accepting a first argument of type 'System.Nullable<System.DateTime>' could be found (are you missing a using directive or an assembly reference?)"
Is it because this DateTime column allows a NULL value (since everyone isn't married in my database)?
Error 1 'System.Nullable<System.DateTime>' does not contain a definition for 'Month' and no extension method 'Month' accepting a first argument of type 'System.Nullable<System.DateTime>' could be found (are you missing a using directive or an assembly reference?) C:Working WebsitesGrannys Clan Address BookDefault.aspx.cs 38 26 C:Working WebsitesGrannys Clan Addres
I would like to know if there is a way that I can use DISTINCT on one column's values but need to show other columns where the value of the DISTINCT column is equal to another table's column
How can i select all columns of table but to distinct by one column? i am tryin to figure it out without success, i know how to make distinct (select distinct column from table, but i need all the values from the table and to distinct by Delcompany.
I'm trying to bind a nullable bit column, which at the moment is mostly null, but I need to somehow convert the null to a 'false' on runtime because it doesn't bind to a checkbox if it's null. But, I am currently unable to change the default value and update all records accordingly - is there a way to do this in runtime?
I created a gridview that is made up of 4 gridviews and using a stored procedure to populate it. I create columns at runtime because the number of columns changes all the time.To make the grids editable I am adding template fields at runtime as I create the columns, this is to ensure that a user is able to edit the cells and some foot values update. Reason why I have four grids is to freeze rows and columns like in excel using javascript. The problem is that performance is very bad especially in IE, the grids take a long time to load. I am not sure if this is caused by the data load or the creation of text boxes. see some of the code below for my _aspx page:
I have only just started to use Reporting Servcies and would like to know is there any way of putting IF statments into the SQL statment depending on the value of a selected parameter.
[Code]....
What I would like to do is when "Parameter!RP_Area.value" = 99 then miss that part of the sql statment out, something like this.
[Code]....
if this is possible and if it is how would I go about doing it?
I have a gridview which displays rows and columns all linked to an sql statement... and all works as normal.
I want to include a new column, that displays an image depending on what the value of the column is. If the column has a value - it will display an image. If the column value is null no image whill be displayed.
My sql is something like:
SELECT c.call_id, title, a.call_id as b_attach FROM calls c LEFT JOIN attachments a ON c.call_id = a.call_id GROUP BY c.call_id,title,description, a.call_id
What's returns from this sql is:
Call_id | title | b_attach 1235 | title goes here | 1235 1382 | another title |NULL
So if there's something in b_attach - diplay image in gridview column, else display nothing in gridview column
I have a table in my database called "Profiles". This holds data on Female and Male personal characteristics.On my aspx, I have a formview in edit mode which is binded to an object data source with a GetDataByUserId Select methodwhich retrieves data from the "Profiles" Table via a DAL.The "Profiles" table has some columns which relates to females only and some just males and some are generic to both.See example below
UserId - / of Type GUID GenreId / of Type BOOL. Hip Size (For females) Dress Size ( For Females) ChestSize (For Men ) TrouserSize (For Men) Weight ( For both )
When the User logs in , they go to an update Page which has the Formview in Edit Item Mode and contains drop down Lists whichare binded to the Users Selected Value. The DDL are in turn bound to their related table such as HIP, Dress, Chest, Trouser etc.bjectiveIf a female user logs in I just want to show them the (Hip Size) DDL and DressSizeDDL in the Edit item template of the formview and not the ChestSize DDL or TrouserSize DDL.At present the GetProfileByUserId returns all colums from the tableMy question is how do I do this and just show DDL which are relevant to the Female or Male Only. In some cases the usermay not have selected an item in the previous form so they could also be NULL.Am i on the right path by writing a Select Query that checks to see if the User is Male or Female by checking the Genre column in Profiles first.Do I also need 2 panels, 1 to hide Female DDLS and the other to Hide MaleDDLs subject to logged in user genre.
I want if the header of a particular column contains a word "S", the header and row turns red. I used following code to make header red and it works fine. How to make it such that the rows also turn red if condition is met ? I cannot hardcode in columns since the Gridview is autogenerate colums as data structure keeps changing.
Protected Sub GridView1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs)Dim HeaderRow As GridViewRow = GridView1.HeaderRowFor Each c As TableCell In HeaderRow.CellsIf c.Text.EndsWith("S") Then c.BackColor = Drawing.Color.OrangeRed End If Next End Sub
I was wondering if anyone could help me. I have a template field which has four itemtemplates that each hold a label in a gridview. These labels are always constant with the same strings. What I want to do is change the css formatting of these four labels depending on the value of a column. So the css formatting would have to be done for each row, not the whole column. I bind the gridview to a dataaccesslayer so there is no sqldatasource on the page. Does anyone have any idea how to do this and where it would be done. I will have the dataview with the data sorted in the correct order. The actual column that is used to alter the CSS will not be in the gridview although I could assign it to the datakeyname if that makes it easier as the data is not sensitive.
<asp:LinqDataSource ID="LinqDataSource3" runat="server" OnSelecting="LinqDataSource3_OnSelecting"> </asp:LinqDataSource> And I have ASPxGridView <dxwgv:ASPxGridView ID="ASPxGridView2" ClientInstanceName="ASPxGridView2Client" runat="server" AutoGenerateColumns="False" DataSourceID="LinqDataSource3"> </dxwgv:ASPxGridView>
In this way Im able to add columns dynamically while handling onSelecting event:
protected void LinqDataSource3_OnSelecting(object sender, LinqDataSourceSelectEventArgs e) { MyModelDataContext context = new MyModelDataContext(); ASPxGridView grid = ASPxPageControl1.TabPages[3].FindControl("ASPxGridView2") as ASPxGridView; if(grid.Columns.Count == 0){ GridViewDataTextColumn txtColumn1 = new GridViewDataTextColumn(); GridViewDataTextColumn txtColumn2 = new GridViewDataTextColumn(); txtColumn1.FieldName = "UserId"; txtColumn2.FieldName = "FirstName"; grid.Columns.Add(txtColumn1); grid.Columns.Add(txtColumn2); } e.Result = from u in context.Users select new { UserId = u.UserId, FirstName = u.FirstName }; }
It is all made simply to test cause my idea is to have solution that makes it possible to use inqDataSource as a datasource for de ASPxGridView but join 2 or 3 tables and show results in this grid.
What I want to ask is if its good solution or is there any other better way to present some views made from couple of tables by join?
Second question is that I have Users and Group and I would like to have one table in which I would have two columns Name and Type For groups type would by group and for users type would be user. I dont have such a table in my database Is it possible to create specific class. Create List of objects of that class and fill it using linq query and the use it as linq data source for that grid ?
clas would be:
pseudocode:
Class MyClass { string Type; string Name; }
or is there any other way to create such a table ?