Datagrid Bound Column needs to be bound to 2 columns?a valu


I have a datagrid with dynamically bounded columns. One column has to display a value that will come from 2 columns in the database. Is there a way to do this?
the code I have for the moment is:
'Add columns
Dim col1 As New BoundColumn
col1.HeaderText ="code")
col1.DataField = "Patient_Code" 'this needs to be 2 database columns!!
Thx alot!
6/24/2004 8:01:37 AM 72751 articles. 3 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 55

Combine the two columns in your SELECT statement eg

SELECT <PatientCol1>+<PatientCol2> AS Patient_Code FROM <Patients>
Use a concatination function if fields are string format.
Mason Woodhams
6/24/2004 8:45:07 AM
I can't do that, I cannot change the stored procedure!

any other solution?
6/24/2004 9:01:32 AM
Create a TemplateField for the new field eg PatientCode

Switch to HTML view find the tag
<wmx:TemplateField headertext="PatientCode"></wmx:TemplateFiled>

In between the opening and closing tags of the new template field enter

<asp:Label id="Label1" runat="server" text='<%# DataBinder.Eval(Container, "DataItem.<patientcode1>") + DataBinder.Eval(Container, "DataItem.<patientcode2>")%> '>

That should do the trick. Not sure how this will work in edit mode, you'll have to play around with it
Mason Woodhams
6/24/2004 10:53:22 AM

Similar Artilces:

Setting Datagrid Column to invisible when Column is an AutoGeneratedColumn NOT a bound Column
Hi all, Just like the title says, I'm trying to set a column to invisible but I'm unable to do so. If I bound the column I can used the code: me.datagrid.Column.Item(1).Visible = False But since I'm wanting the column NOT to be bound (there are a number of sql scripts that populate the same datagrid so I cannot bound all the columns since the columns are different for each script etc etc etc) how do I set an AutoGeneratedColumn to invisible?? Please help! - VB.NET, C#, Silverlight, Javascript, HTML, CSS, T-SQL, MySQL and SQLitewww.headshot...

DataGrid: Bound Column vs Template Column
I have a datagrid with a bound column and a template column as given below.When I scan through the grid, I get the value of the first column (bound column). However, I cannot get the value of the second column (Template Column). I can see the data in both columns though.////////////////////////////////////////////////////////////////////////////////////<AlternatingItemStyle BackColor="#e0e0e0"></AlternatingItemStyle><Columns><asp:BoundColumn DataField="Facility" HeaderText="Facility"> </asp:BoundColumn><asp:TemplateColumn HeaderText="Facility2"><ItemSty...

datagrid columns bound to columns from different tables
Hi, I have a dataset with multiple tables. Is there a way to bind each of the datagrid's columns to a column from a different tables? Thanks in advance! BR The bottom line, yes you can, but it would take some custom methods getting called from a template column and some other fancy tricks. But, the datagrid is designed and works best when it's given it's one datasource. If you need data from different columns in different tables, I would make a custom datatable that reflects the columns you need and use that custom datatable has the datagrid's datasource. Don't think of t...

datagrid update bound column value
I'm nuts - what I've used before isn't working.  Have a datagrid with add, edit, update, delete functions.  Everything works except the update function - getting blank when trying to retrieve the indexItem key. (set keyfield in datagrid, also have first column as bound column)  On the edit button click, I can write the bound column value to a label and then reference that, but surely there's a clearn er way?  Any help? <asp:datagrid id="dgPub" runat="server" autoGenerateColumns="false" DataKeyField="id"><Columns><asp:BoundColumn visible="false" dataFi...

in a grid how to find a particular column is bound column or template column
hi,  Any one know how to find a particular column is bound column or template column or button column,etc in a grid Advance thanks   hi...use this dim label1 as Label=ctype(GridView1.FindControl("name"),Label) Hope This HelpsBhaaratRemember to click "Mark as Answer" on the post that helps UMy Blog find a particular column is bound column or template column no to find that particular column  Hi,please excuse me if iam wrong.i found that bount columns values are directly renders to a <td>  where template columns create some cont...

Issue with Template Columns & Bound Columns while updating the data in a GridView control
Hi, I'm facing the below problem (In general, ObjectDataSource is driving me crazy ! ) I have a simple gridview control and an ObjectDataSource is used to populate the grid. I'm trying to update a row and the corresponding tableadapter methods & stored procedure are in place. Each row has 2 checkboxes and 2 textboxes in edit mode. When the change the values in edit mode and hit update, the checkbox values changed are saved into the Database properly, whereas the textbox values are not being saved. If the textbox column is a bound column then the column is updated with <NULL> in...

How to subtract two date columns(bound) of a Datagrid and display the result in the third column?
Hi Everyone,I  have two date columns(databound-coming from SQL database) in my datagrid, 'start date' & 'end date'. I need to calculate number of days with 'end date- start date' and display the result in the third datagrid column. i.e.: column2-column1 = column3Any help anyone?...ASAP please got a deadline to meet :) (SOS!!!)Many Thanks in advance,Arty.Aartee...we live more than once! Hi, there are several ways of doing it. One of them is creating a label in the TemplateColumn, use the Helper function to calculate the number of days.<ItemTemplate>   <...

How to subtract two numeric columns(bound) of a Datagrid and display the result in the third column?
Hi Everyone,I  have two numeric columns(databound-coming from SQL database) in my datagrid, 'PromoPrice' & 'CostPrice'. I need to calculate 'PromoPrice- CostPrice' and display the result in the third datagrid column. i.e.: column2-column1 = column3Any help anyone...Many Thanks in advance,Nico. In your query do this:Select .... , (PromoPrice - CostPrice) AS Answer, .....FROM yourTableKeep in mind you can do math functions in queries.DarmarkMark as Answer, if this reply answers your post. Hi Darmark, thanks for your fast answer.The fact is I'm using a single "select function"...

Dynamic change the 'Read Only' in datagrid(template column/Bound column)
I create few template column and bound column in datagrid. One of the template column contain the StudentMark. I want to know how to change that column to (Read only) or "Not" (Read only) when click the edit button. It is based on a dropdownlist to determine to read only or not. I think i must use the template column, since i need to do the validation to the StudentMark. (For example, If select value '1' in dropdownlist, the "StudentMark" is become 'Read only' and select '2' become vice versa. I was success to bind the datagrid and "StudentMark" become a textbox...

Bound datagrid columns
Please help!! I have a dataset being filled by an adapter and stored procedure. My datagrid is bound to the dataset. If a blank field is returned from the database, I do not want the relevant bound column in the datagrid to be displayed. Does anyone know how to do this....?? Thanksss You can hide the column or cell in the ItemDataBound event. Do you mean that if none of the rows contain a value for a particular column, then you want to hide the column? If so then your best option would be to remove the column from datasource before performing the databinding. In case ...

DataGrid Bound Column...
Hi, hopefully a quickie :-) I have a datagrid with a bound column displaying a value returned from a database. I wanted to sort the value in the grid numeric ascending when the column is clicked, so I added a sort procedure and this works fine. Next, I decided to replace the text header to be an image. So I added a headerimageurl: <asp:datagrid id="grid1" onsortcommand="grdSort" onItemCommand="grdItem" ... > <asp:boundcoumn ... headerimageurl="\image.jpg" sortexpression="counter"> </asp:boundcolumn> <...

Bound Column in a Datagrid
I just have a column in a datagrid which is bound a bit field in SQL Server so it displays 'True' or 'False' in my datagrid.  I'm wondering how to display this to a more user-friendly value like 'Yes' or 'No' ?  Thanks. <Columns>     <asp:BoundColumn DataField="Ratings" SortExpression="Ratings" HeaderText="Ratings"></asp:BoundColumn> </Columns> Here is some sample code via (Replace "online" in the code with the name of your bit column) <code> <asp:DataGrid id="YourID" runat="server" AutoGe...

Bound Columns #2
The following code is trying to update three columns. One of the columns is bound to a list box, the other two are bound in the code as follows. This gives me an error message that the two array bound columns are null values. Can anyone see a mistake that I'm making - let me know - thanks!!!!! WLong id[3]; WLong index[3]; //WMessageBox::Info( this, "Info", str); query_Addcountry->Open(); query_Addcountry->SetRowsetSize(1); query_Addcountry->BindColumn(2, SQL_C_SLONG,id); query_Addcountry->BindColumn(3, ...

converting Bound Column to Template Column
Hi All, I wanted to convert the bound column in the grid to Template column. How could I do this dynamically? I know it can be done using the edit column dialog box, but I need to do that in the code behind. waiting for your reply. Thanks, regards,   Hi Techwork, Not tested and incomplete but just to get you going: Iterate the Columns property and find the BoundField with:Columns[i].GetType().Name == "BoundField" and((BoundField)Columns[i]).DataField == ... Remove this BoundField from the Columns Collection with:Columns.RemoveAt(i); Create a new TemplateField insta...

Web resources about - Datagrid Bound Column needs to be bound to 2 columns?a valu -

Politics, Political News - The Capitol Column
Covering the politics of science, technology, business, entertainment, Capitol Hill, and health.

Column (typography) - Wikipedia, the free encyclopedia
In typography , a column is one or more vertical blocks of content positioned on a page, separated by gutters and/or rules . Columns are most ...

Column 8
&quot;There is a netted swimming enclosure in Davidson Park (or Garigal National Park, near Roseville Bridge),&quot; reports Norman Carter, of ...

Paris attacks: column in IS magazine warns of 9/11-scale attack to come
Under the byline of a hostage British journalist, Islamic State warns that it may attempt a terrorist attack even bigger than 9/11.

The 10 Best Online Columns Of All Time . . .
Former Biglaw partner and inhouse columnist Mark Herrmann identifies the ten best online columns of all time.

Should the Washington Post’s Ties to Reagan Library Be Disclosed in Columns Attacking Bill O’Reilly?
Much has been discussed regarding the recent spat between Washington Post columnist and Fox News contributor George Will and Fox News host and ...

Patt Rall Column: A little 'Therapy' goes a long way
Patt Rall Column: A little 'Therapy' goes a long way Bemidji Pioneer The entire ensemble is small but intense in their artistic pursuits: Norwood ...

In the middle of a NYT column explaining research into human psychology: "It had no effect on people ...
... in the Middle East among people who identified as politically conservative. It had no effect on people who identified as liberal. The column ...

Tim O'Sullivan column: Giving thanks to our father figures on this holiday
Concord Monitor Tim O' Sullivan column: Giving thanks to our father figures on this holiday Concord Monitor That man would be Celtics basketball ...

‘Carol’ Producer Stephen Woolley: Todd Haynes Film A Cautionary Tale For Threatening Times – Guest Column ...
As the Oscar-nominated producer of The Crying Game and Made In Dagenham , stories about gender and equality have always spoken to me, and none ...

Resources last updated: 12/8/2015 7:14:33 PM