Forms Data Controls :: Getting The Value Of A Data Item Which Is A Simple Data Type?
Jul 9, 2010
I'm binding my object data source to a method that returns a list of ints (List<int>).
The object data source is being used by a DataList.
<asp:ObjectDataSource ID="objectDataSourceYears" runat="server" EnableCaching="true" CacheDuration="Infinite"
SelectMethod="GetYearsUnderArticles"
TypeName="Project.DAL.Services.UmbracoService"></asp:ObjectDataSource>
My question is:
How do i display the values of the ints. Normally, I would use DataBinder.Eval(Container.DataItem, "FieldName"), but what in this case, since the object itself is the value?
View 3 Replies
Similar Messages:
Apr 2, 2010
I am having problem with rowdatabound, want to add if conditions intact, i am using teh following two if conditions and they don't look right. i found them on google.
If e.Row.RowState = DataControlRowState.Normal Or e.Row.RowState = DataControlRowState.Alternate Then end if
If e.Row.RowState = DataControlRowState.Edit Or e.Row.RowState = 5 Then end if
With datagrids i use these and they work excellent:
If e.Item.ItemType = System.Web.UI.WebControls.ListItemType.Item OrElse e.Item.ItemType = System.Web.UI.WebControls.ListItemType.AlternatingItem Then
end if.....
View 2 Replies
May 22, 2010
I've been looking all afternoon, but the best I've been able to do when the user selects a row is to get at the item with each field in Text format.I would like, ideally, to be able to get at the row in its original MyDataType that I bound. I'm using an ObjectDataSource, and the grid (a RadGrid in this case, but its much the same deal as gridview) know the type not only of the rows by also of each and every column.I'm stymied that I'm stuck in the days of error-prone referencing columns by their name. Instead of:
grid.Items[grid.selectedIndexes[0]].item["myColumnName"]
I'd much rather be doing something like
grid.Items[grid.selectedIndexes[0]].item.myColumn
But for the life of me I can't figure out if its even possible. The grid is retaining viewstate, so it still has all of the data.
View 2 Replies
Oct 17, 2010
I created this simple dynamic data form using Dreamweaver cs4, ASP VB technology and a MySQL Database: I love all of the extended functionality that VWD 10 provided, but the most important functionality for me is to be able to completely design a dynamic data table any way I want.
I noticed after researching extensively that the GridView, ListView and DetailsView templates still leave me very limited in what I can design. My question: is there a way for me to design a table in a details page with record placeholders that will be fetched from a master/detail page set?
View 1 Replies
Dec 18, 2010
I have created a simple application to edit data in an access database using gridview but its not working , the results are shown correctly , but when i click update nothing happens..
Here is my code
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataSourceID="SqlDataSource1" EnableModelValidation="True" DataKeyNames="id" >
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="id" HeaderText="id" InsertVisible="False"
SortExpression="id" />
<asp:TemplateField HeaderText="NAME" SortExpression="NAME">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("NAME") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("NAME") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="FATHER_NAME" HeaderText="FATHER_NAME"
SortExpression="FATHER_NAME" />
<asp:BoundField DataField="MOTHER_NAME" HeaderText="MOTHER_NAME"
SortExpression="MOTHER_NAME" />
<asp:BoundField DataField="CLASS" HeaderText="CLASS" SortExpression="CLASS" />
<asp:BoundField DataField="gram" HeaderText="gram" SortExpression="gram" /
<asp:TemplateField HeaderText="Remark" SortExpression="Remark">
<EditItemTemplate>
<asp:DropDownList ID="PS" runat="server" SelectedValue='<%# Bind("Remark") %>'>
<asp:ListItem>PASS</asp:ListItem>
<asp:ListItem>FAIL</asp:ListItem>
<asp:ListItem>APPEARED</asp:ListItem>
<asp:ListItem>NOT APPEARED</asp:ListItem>
<asp:ListItem></asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Remark") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConflictDetection="CompareAllValues"
ConnectionString="<%$ ConnectionStrings:ConnectionString2 %>"
ProviderName="<%$ ConnectionStrings:ConnectionString2.ProviderName %>"
UpDatecommand = "update [REGULAR] set [NAME] = ?, [FATHER_NAME]=?, [MOTHER_NAME]=?, [CLASS]=?, [gram]=?, [Remark]=? where [id] = ?"
SelectCommand="SELECT [id], [NAME], [FATHER_NAME], [MOTHER_NAME], [CLASS], [gram], [Remark] FROM [REGULAR] WHERE (([CLASS] = ?) AND ([SCHCD] = ?))">
<SelectParameters>
<asp:ControlParameter ControlID="DropDownList3" Name="class"
PropertyName="SelectedValue" Type="String" />
<asp:ControlParameter ControlID="DropDownList1" Name="schcd"
PropertyName="SelectedValue" Type="String" />
</SelectParameters>
</asp:SqlDataSource>
View 1 Replies
Aug 30, 2013
1)table student
studentno varchar(50)
hobby1 varchar(40);
hobby2 varchar(40);
hobby3 varchar(40);
2)if record in data database such that
hobby1 hobby2 hobby3 in this maximum is one must be chose
like
here studentno hobby1 hobby2 hobby3
1 cricket null null
2 null hockey null
3 null null tennis
if i want to write function in mysql if i pass the studentno
i want to get the hobby of respective student
like select functionname(1)
your hobby is cricket
like select functionname(2)
your hobby is hockey
ike select functionname(3)
your hobby is tennis
View 1 Replies
Jun 21, 2010
I want to do is create a simple page which allows a user to post data into a data table. It should not allow them to view, update or delete any data.
Is there a good online tutorial which would guide me through how to do this in Visual web developer 2008?
I have connected a db, and can add "SELECT" controls to view forms, but I need to be able to INSERT to the table.
View 4 Replies
Mar 26, 2011
not quit sure where I've go wrong with this but hopefully someone might have an idea why this isn't working:
This what I thought would work:
[code]....
But it's not! what I get for the OnClientClick attribute is: "DeleteRowKey=<%# dataBinder.Eval(Container.dataItem, "idx_mstrWord") %> "
I've tried several variations (EVAL, BIND, specifying the container and not specifying the container),
none of which gives the expected results; OnClientClick="DeleteKeyRow=12345"
If I add a label and set the text to: <%# dataBinder.Eval(Container.dataItem, "idx_mstrWord") %> I get a number which is what I should but if I try to get it to embed it so my cleint script can work with the data all I get is binding command.
What am I doing wrong? I really don't want to have to kludge around with some hidden field and then have to search through the grid to get at this data key. I need this key on the client side in order to provide additional details in my confirmation popup modal.
View 2 Replies
Dec 3, 2010
I have a GridView on a page for maintainance of the database (mdf). Under this GridView1 I have a FormView1 where I use the ItemInsertTemplate to Insert new rows in my database (which shows the data in GridView1). The first textbox (BIDTextBox) i have on this template, contains text which identify a person. I would like to have a routine which checks if the same value that is entered in the BIDTextBox allready exists in the database. This routine should be fired upon leaving the control BIDTextBox.
I have tried with some stored procedure in my database, but that dosn't seem to do the trick. The most logical to me seems to do a loop thru my table "Ansatte" in my database using sql, selecting any occurence from the field "BID" in my table "Ansatte" that is simillar to the text entered in the BIDTextBox.
View 6 Replies
Nov 25, 2010
when i am selecting an item in dropdown list datasource is bind and after another selection it is bind again .but i want it bind only once.
View 4 Replies
Dec 8, 2010
I am having an issue with a simple databind to a datagrid. What happens is that for some reason, the first character of the data going into the 4th column is getting placed at the end of the data in the third column; but only on the first row. Here is an example of what I mean:
Form ID
Employee No
Associate Name
Start Date
End Date
Form Status
1234
5000187
Stan Marsh1
1/16/2010
11/30/2010
Approved
1234
5000187
Eric Cartman
11/16/2010
11/30/2010
Approved
1234
5000187
Kyle Broflovski
11/16/2010
11/30/2010
Approved
As you can see, in the first row of data, a "1" has been moved from the Start Date column to the Associate Name column. Because this is a databind I don't see how this is even possible. I'm just curious if this is a known issue or just some random fluke. Here is the relevant code:
[Code]....
View 2 Replies
Mar 15, 2011
I have a dropdownlist and a button(btnSend).
protected void btnSend_Click(object sender, EventArgs e)
{
InsertIntoTemporary();
LoadAddressdetails();
MassSendOut();
}
What i need to do is as follows;
1) Once i select the item in the dropdownlist, it will extract data from my sql query which is :
string mySQL = "SELECT * FROM examtimetable WHERE subject_name= '" + dd_cat.SelectedValue + "'";
Once seleted,it will display everything in a gridview1.
subject_id subject_name admission_no date venue seat_no
View 2 Replies
Aug 23, 2010
i have a dropdownbox and a gridview what I want is to have a list item which populates all data in a gridview. I have tried using list item selected value=0 but to no avail. what is the easiest way to achieve this?
View 1 Replies
Sep 17, 2010
how to get the variable value to the hyperlink postbackurl
Here the code that i have in Gridview
<asp:TemplateField HeaderText="Process" ShowHeader="False">
<ItemTemplate>
<asp:Button ID="Button1" CssClass="btn" PostBackUrl='<%# String.Format("http://googlemaps.com?ID={0}&Name={1}&Address={2}", Eval("No"), Label2.text, Eval("Id"))%>'
runat="server" Text="Process" OnClick="LinkButton1_Click" />
</ItemTemplate>
</asp:TemplateField>
I have ID and Address parameter coming from the dataset/Datasource but not the Name parameter.
Is there a way that I can pass the non databound item to the postBackUrl query string.
View 2 Replies
Feb 2, 2011
I have come from MS Access and am working through a couple of textbooks on ASP.NET 4. I am using the Gridview control connected to an SQL data source control.
As an exercise I am converting my simpliest MS Access page which is simple a form to request a new stock item in our engineering stores. I have a normalised table called [stock_requests] and part of this is a field calle [failure_mode]. This field is an integer and there is another table listing the possible values for this field.
This other table is called [failure_modes] and has two field:
[id] < the primary key
[mode] < the text to be displayed
In my main table [stock_requests] in the field [failure_mode] I store the [id] from the [failure_modes] table for the applicable record in the [failure_modes] table. So for example if someone wanted to select "Catastrophic" as the failure mode the [stock_requests].[failure_mode] field would be 1; if the user selected "Gradual" as the failure mode the [stock_requests].[failure_mode] field would be 2 etc.
Now, the gridview wants to display "1" or "2" but I want to display "gradual" or "catastrophic" without using views and all the headaches that brings. I have managed to sort out editting by using a templated field where I have a drop down list in this cell and I databind to a second SQL data source (imaginatively called SqlDataSource2).
what is the best method for displaying the text 'Catastophic' or 'Gradual' etc. when in normal mode (view mode)? Is it another templated field and what is the basic approach I should use? I reckon I should be able to work it out once someone points me in the right direction.
View 6 Replies
Aug 16, 2010
I have seen several Web Sites that use GridViews that have lookup fields with different Value and Text Fields (as in drop down lists) but I can't seem to figure it out how to display the Text Field in the Item Template when the Text Field is not in the datasource. .
Here's what I have. I have a Gridview whose datasource is a Linq to SQL Invoice table, e.g.
InvoiceID
CustomerID
InvoiceNumber
THe Customer table is related to the Invoice Table thru the CustomerID. The relationship is defined in SQL Server and is displayed in the DBML.
I have created a template field for the CustomerID field in the Gridview. I would like to display the CustomerName when the Item Template is displayed and a DropDownList in the Edit Template. The DropDownList works great, but I cannot seem to figure out how to display the CustomerName in then Item Template.
I seem to remember seeing in some video that you can simply drag the CustomerName into the CustomerID Item Template Field. But I can't seem to find the customerName field. The DataSource includes the Customer Table because of the relationship, but no fields are displayed.
I suspect this is real simple, but I cannot seem to find an article or video that explains how to do this.
View 11 Replies
Jan 27, 2011
I am saving grid data. Grid contains one textbox in item template column. But it was not saving any data, which was entered in textbox(Just saving 'NULL'). There was not error while debugging. Below is code i am using.
[Code]....
View 2 Replies
Sep 3, 2010
I'm currently working on a project and I want to make as much things as possible performing on client side - with as little loading as possible. The project consist of three "main" pages. On one page I use jQuery DataTable plugin which is working great. One page has tabs (using jQuery). I want to put datacontrol (repeater) on this site and when user selects one item in dropdown, data in repeater loads on client side, without performing the action on server.
View 4 Replies
Oct 27, 2010
I use a ItemDataBound for a repeater.But i use 2 kinds of linq querys to bind it.Some of them has a MerkID, and some doesnt have this item.So its easy i need to do this:
if(e.Item.DataItem.Contains("MerkID"))
{
//Code for linq query 1
} [code]...
So of course the if selection doesnt work, but how can i do that? I already tryed this:
DataRowView drv = (DataRowView)e.Item.DataItem; if (drv.Row.Table.Columns.Contains("MerkID"))
But that doenst work because he cant convert it to a datarowview because its a linq class.So what to do? Right now i use a try and catch, but there are better solutions i guess...
View 8 Replies
Jun 22, 2010
I am trying to use a repeater control that will display a hyperlink control. For the text of that Hyperlink control I would like to concatenate to fields from my data source (lets say First Name and Last Name). How would I do this appropriately for the Hyperlink control within an ItemTemplate?
View 3 Replies
Nov 22, 2010
<asp:Image ID="Image1" runat="server" ImageUrl='<%# (Eval(DetailsView14.DataItem, "P_Picture"), "http://ornament.com/images/national/{0}.jpg") %>' />
Can not figure out what is wrong with this statement
View 4 Replies
Feb 18, 2011
I would like column in a table to be a link(not using hyperlink field). What data type do I need to use to make this possible?
View 2 Replies
Jan 29, 2011
I have one table "EmpDetails". Fields of the table are empid, empname and empimg. I have stored employee details in these three fields. Now i want to retrive empname and empimg field in my web form. To do this i have taken one data list control. I have wriiten all code to get desired data but i am only getting empname from data base, not getting his/her image from databse. let me tell you i have stored images in database as a binary data. so how to retrive this binary data in datalist as an image.Below is my datalist control.
<asp:DataList id="ItemsList"
BorderColor="black"
CellPadding="5"
CellSpacing="5"
[Code]....
View 2 Replies
Jul 23, 2010
I have a mySQL datasource pulling back data from a query and populating a formview in edit item mode ( I only use this mode ). All is good. Business logic is such that some dates can be null. When I was putting the null or "" dates into a text box there was no problem, some users had problems with dates so I used the datepicker lite control, now the null or "" dates cause a data type conversion error stating that an empty sitrng "" cannot be cast to type date. It basically barfs here
<%# Bind("OrderDate", "{0:dddd d MMMM}") %>
This is obviously in the asp source portion of the code and there is no code in the classic VB section fo the page, it is all done by drag and drop controls and databinding.How can I fix this error and yet still allow users to put in a date, when applicable, and save the update with the new date added. eg I dont want to take out the databind if I can no longer save that field back to the db.
View 5 Replies
Mar 9, 2011
I am tring to write some custom filters for a gridview and want to base the filters available based on the datatype of the Columns in the GridView. How would I go about determining the datatype of each column?
View 1 Replies