Dynamic Controls - Add New Rating Of Selected Item Into Database

Jul 23, 2010

On my page I have a list of items with ajax rating controls next to them. These controls I create dynamically from Page_load where I give the rating controls the rating of each corresponding item from the database. The problem is now that when the rating-event is fired I want to go to my event handler och add the new rating of the selected item into my database, but between my click and the event handler-method is fired the Page_load method is run, where all ratings is set from the database again, which means that the new rating I clicked on was restored and that the new rating I was supposed to update my database with will be the old rating already in the database. I create my ratings like this:

SqlDataReader r = cmd.ExecuteReader(); //calling a stored procedure
RadRating rating = new RadRating();
rating.Rate += new System.EventHandler(rating_Click);
rating.ID = r["id"].ToString();
rating.AutoPostBack = true;
rating.Value = Convert.ToDecimal(r["Overall_rating"].ToString());

In my event handler:

protected void rating_Click(object sender, EventArgs e){
RadRating rt = (RadRating) sender;
double myRate = Double.Parse(rt.Value.ToString());
updating database with myRate
}

From what I heard I need to recreate the dynamic controls i Page_load in order for them to persist throug postbacks, but when I do this the old rating writes over the new rating that I clicked on and need to use for database insertion. How can I solve this?

View 5 Replies


Similar Messages:

Web Forms :: DropDownList Selected Item Is Lost And Default Item Is Inserted In Database On Button Click

Jul 16, 2012

I bind dropdownlist in my page

protected void Page_Load(object sender, EventArgs e) {
BindDropDownList(DDL1, "city1", "name", "ID");
DDL1.Items.Insert(0, new ListItem("select city", "0"));
}

And SP

LTER procedure [dbo].[city1]
as
begin
select id,Name
from city
end

And design code

 <asp:DropDownList ID="DDL2" runat="server" CssClass="daddsd">
</asp:DropDownList>

And here is imagebutton code that when click on it update data into table

protected void ImageButton_Click1(object sender, ImageClickEventArgs e) {
string data = Server.UrlDecode(Request.QueryString["BehCode2"]);
SqlCommand _cmd = new SqlCommand("insertinfo", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();

[Code] ....

Here when i click on button it insert all data into table but it didn't insert my selected item from dropdownlist it insert select city that i define in page_load

 DDL1.Items.Insert(0, new ListItem("select city", "0"));

And when i delete this code from page load it insert in table first row of my table it didn't insert my selected item from dropdown list.

View 1 Replies

Selected Item In Dynamic Drop-down?

Oct 14, 2010

I'm trying to make the selected item the value of an asp:Label if this is possibleI am putting my drop down list in like this

For ddlAdults As Integer = 1 To strNumberSlept
CType(e.Item.FindControl("ddlEditAdults"), dropdownlist).Items.Add(new ListItem(ddlAdults.ToString(), ddlAdults.ToString()))
Next ddlAdults

And I need to add a selected item in to be the value of strSelectedItem

Dim strSelectedItem = CType(e.Item.FindControl("lblAdults"), label).Text

Not sure how to add this in dynamically

View 1 Replies

Data Controls :: Set RadioButton Selected Item True Using Value From Database

May 7, 2015

I have House_info table with Storetype column and I have radiobuttonlist in my page below is code

<asp:RadioButtonList ID="RBLType" runat="server" RepeatDirection="Horizontal">
<asp:ListItem Value="Galary"><span style="color:#676767">Galary</span></asp:ListItem>
<asp:ListItem Value="Product"><span style="color:Red">Product</span></asp:ListItem>
</asp:RadioButtonList>

Now I want if in Storetype column in database was="Product" then radiobutton item with text="Product" selected=true  and if in store type column was="Galary" radiobutton item with text="Galary" selected="true"

How I can do it?

View 1 Replies

Data Controls :: Delete Selected Item From Database Using DropDownList

May 7, 2015

I want to delete selected item of dropdownlist on Delete button click

Hint :1-It should also delete value from Database.
 2-I want to Delete with the id of that selected item.

View 1 Replies

Web Forms :: How To Set A Selected Dynamic Menu Item To False

Feb 10, 2011

Does anyone know how to set a selected asp.net dynamic menu item to false? I have multiple menus and when someone selects an item from one of the dropdown menus it changes color. If I were to select an item from a different menu I need the other menus not to have the selected option anymore.

View 1 Replies

Forms Data Controls :: How To Filter Item Of Database In Dynamic Rows In GridView

Aug 19, 2010

I have used this gridview in my project nad its working fine.

View 2 Replies

Web Forms :: Dynamic Drop Down List With Selected Item Change?

Jul 14, 2010

In my application i used drop down list dynamically so that if i enter the the value in the text box that many drop down list genrated with data from database. if i select the different iteam in the drop down list it will not changed it remains the first iteam of the dropdown list. if i use post back event is true in code part that drop down list is not visible.

nt i = 0; i < rows; i++)
{
TableRow row = new TableRow();
for (int j = 0; j < column; j++)
{
TableCell cell = new TableCell();
[code]...

View 5 Replies

Forms Data Controls :: Insert Database NULL If Drop Downlist Item Is Not Selected?

Sep 1, 2010

on my aspx I have the below DDL

<asp:DropDownList ID="ColorDDL" runat="server" DataSourceID="ColorObj"
DataTextField="Size" DataValueField="BustId" Width="150px"
AppendDataBoundItems="True">
<asp:ListItem Value="-1">(Optional)</asp:ListItem>
</asp:DropDownList>

If the user does not select an item I get an exception when i call the ObjectDataSource Method and DAL as below to insert into database

ProfileObj.InsertParameters["ColorId"].DefaultValue = ColorDDL.SelectedValue.ToString();

What I want to do is insert a database NULL instead.

View 3 Replies

AJAX :: Rating Control Average Rating And Postback On Same Rating?

Feb 20, 2011

I have a rating control that shows the average rating of a user supplied posting (think of a forum post that others will rate). So if the average rating for that posting is lets say 3 out of 5 all users will see 3 stars. If someone wants to rate the posting, then they could click lets say 4 stars and I save the rating to the database, re-average the current rating and display the result (which may or may not still be 3 at this point). So far so good. The problem comes in when a user wants to agree that it's 3 stars. Since the rating control currently shows 3 stars, choosing 3 again does not cause a postback. In my case even though the value didnt technically change, I need to capture the users choice so I can average it in and save that users rating. I also modify the UI so that I can show each user of the site what he/she choose as a rating.How can i get the control to let me know that a user choose a star rating even if its the same one the control is currently displaying?

View 3 Replies

How To Get The Selected Item In Drop Down List And Insert It Into Database

Jan 29, 2010

how do i get the selected item in the drop down list and insert it into database (togethi populated the drop down with the values from the tables in database. It is dynamic, not static.i have a button in the gridview called 'add'. so when user clicks on it the row (whatever columns in the row) would be inserted into database. i am doing insertion/create for this.

View 14 Replies

Forms Data Controls :: Get The Selected Item From The Listbox In The Selected Index Changed Event

Feb 28, 2011

How to get the selected item from the listbox in the selected index changed event. I tried: Label1.Text = ListBox1.SelectedItem.Text; It is giving me object set to null reference.

foreach (ListItem item in ListBox1.Items)
{
if (item.Selected)
{
//lblResults.Text += item.Text + "
";
Label1.Text = item.Text;
}
}

No use, no value coming in to label.

View 5 Replies

Web Forms :: Insert Radio Button Selected Item To Database

Jun 30, 2012

I have 2 radiobutton  

1 text box and   1 button

radiobutton1

radiobutton2

And this is my table

price name Id 

View 1 Replies

Forms Data Controls :: How To Implement A Rating Mechanism Into Database Design

Mar 5, 2010

I have the attached database design.

The database has been designed for a tradesman web site, i.e. Plumbers, Builders etc. The two main tables are tblCustomer and tblTrader which will stored data from two frontend web pages where the customer and trader can enter their personal details. After a customer enters their personal details (i.e. registers through the site) they will then be directed to a child page where they can progress to entering a specific job attached to a specific trade (i.e. Plumber) and trade type (i.e. Bathroom Installation), once a customer job has been entered I want these details to be emailed to all the trader_email addresses from tblTrader, from this email alert the traders will then enter the system and offer quotes to the customer through tblTraderQuote where the customer will then accept the best quote for them.

What I also want to implement is some sort of rating option that will allow the customer to rate their trader, either something like ebay's feedback or just a simple 1-5 rating option? How can I implement this into my database design or is this something that should be performed within the programming layer?

View 3 Replies

Data Controls :: Display Star Rating From Database Inside DataList Control

Sep 20, 2015

In .aspx page:

<asp:DataList ID="dataList1" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
<ItemTemplate>
<div class="single-blog-post">
<h3><%# Eval("PName") %></h3>
<div class="post-meta">

[code]....

I want to set the ImageUrl property of IMAGE control in code.

View 1 Replies

AJAX :: How To Use Rating Control For Song Rating In A Musical Website

Jan 29, 2011

I am now doing a project mobile musical website. I have used Ajax Toolkit in my last project and so that I know how to install it and work with it...

I have used CalenderExtender, TextboxWatermark, Password Strength, etc. But I am not familiar with the rating control. How does it work ?

View 1 Replies

AJAX :: Implement Half Star Rating Using Rating Control

Aug 18, 2015

Article [URL] .....

Above article show rating only integer part .

How can i show decimal rating on ajax rating control not any labels?

View 1 Replies

Web Forms :: Redirecting A User Selected Item In A Drop Down List To Another Item?

Feb 10, 2010

I have a list with 2 sorts of items. Items that have actual values (1,2,3,4 etc) and items that are like group headings so all their values are set to 0. If someone decides to select a group heading - which has a value of 0, is it possible to redirect them to my 'Select an item' item which has a value of ""?

If worse comes to worse, I can just reconstruct the entire list, although if possible I'd like to avoid it.

View 4 Replies

MVC :: DropDownList Can Either Select Item OR Save Selected Item Back To Controller?

Jul 7, 2010

I have a project that queries a set of times from a database and uses these entries to populate a dropdownlist. Once the page is loaded, the user can select one of the items in the DropDownList. When the "Save" button is clicked, the Selected item value is returned to the [HttpPost] version of the controller action. This item is then stored into session. If the system returns to the page containing the dropdown, I want the saved Value to be selected in the DropDownList. What actually happens is that the DropDownList is always set to be the first item in the list.

Database Table: This data has been imported using Link to SQL

[code]....

View 4 Replies

Rating Control Current Rating To Double Rounding?

Mar 19, 2010

I am trying to convert 22 rating control currentrating values to a double instead of int

I am also displaying in a label control so it is converted to String here is what I have

[Code]....

My display label displays

Rating is x stars out of 5.0 stars

I also record the results in a decimal 1.1 form

I did Convert.ToDouble(rate1.CurrentRating) + Convert.ToDouble(rate2.CurrentRating) .....

but I get a 7 digit after 0 return, how do i round that to a single point?

View 1 Replies

AJAX :: How To Give Half Rating In Rating Control

Oct 11, 2013

I am using AJAX Rating Control.I want half star rating.For Example,If My AVG Rating Count is 3 Then My Stars Wants to be show 3If My AVG Rating Count is 2.5 Then My Stars Wants to be Show 2 1/2 mark i.e., two & half stars.But,it was not showing then also it is showing 3 stars.

View 1 Replies

C# - Select Item In Formview Based On Drop Down Selected Item

Jul 4, 2010

I am trying to get a drop down and a form view to work together. I've never used form views before. I also am using the entity framework to do everything. This is also my first time with it.

I want to be able to have a drop down, that is populate from the same data source as the form view. So far that works fine.

I then want to be able to change the drop down item, and it change the form view item that is displayed. I cannot figure out how to make this work.

View 3 Replies

Dropdownlist / Every Time Selecct An Item, First Item In List Gets Selected?

Feb 3, 2010

i use a dropdownlist in a page, with its items taken from a mysql database

i also use autopostback property...my problem here is that, every time i selecct an item, the first item in the list gets seelected

View 5 Replies

C# - Dropdown - Get The Value Of The First Item In The List Regardless Of What Item Is Actually Selected

Dec 3, 2010

I have a drop down list control populated with items and some code to take the currently selected item value. The problem is I only get the value of the first item in the list regardless of what item is actually selected. Here is my code to populate the drop down:

protected void displayCreateCategories()
{
StoreDataContext db = new StoreDataContext();
var a = from c in db.Categories
orderby c.Name
select new{catName= c.Name,
catId=c.CategoryID};
ddlCategory.DataSource = a;
ddlCategory.DataTextField = "catName";
ddlCategory.DataValueField = "catId";
ddlCategory.DataBind();
}

To get the value of the currently selected item which in my case is always of type integer I do label1.text=Convert.toInt32(ddlCategory.SelectedValue); I get the selected value, but it is always for the 1st item in the list. I'm pulling my hair out over this.

View 2 Replies

AJAX :: Rating Control Bind With Database

Apr 23, 2010

i am trying to bind rating control from my database. example like. Orkut Answer streangth. i have three option Yes, No and cant say and according database value, i want to show stranth for that option.

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved