Retrieve The Data From The DB To The Gridview Based On The Selected Value From Another?
Jan 29, 2010
I am a beginner in Dot net Domain.Presently Im creating a web portal for one of our client.In my portal i have displayed the News headline and a button for details in a Grid view. when i click on the button it has to show the detailed news from DB in another grid view. I have done a code on it.,but it shows some error.I have displayed the code below.
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType != DataControlRowType.Header && e.Row.RowType != DataControlRowType.Footer && e.Row.RowType != DataControlRowType.Pager)
{
Button btn = (Button)e.Row.FindControl("Button12");
btn.CommandArgument = e.Row.RowIndex.ToString();
}
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "newsbtn")
{
int index = int.Parse(e.CommandArgument.ToString());
string key = GridView2.DataKeys[index].Value.ToString();
SqlDataAdapter da = new SqlDataAdapter("select **img,news,detail** from News where news=@n", connect.con());
da.SelectCommand.Parameters.AddWithValue("@n", key);
da.Fill(ds, "more");
//if (!IsPostBack)
//{
GridView1.DataSource = ds;
GridView1.DataBind();
//}
}
}
The error it shows is: DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'detail'.
i am still stumped with this operation: i am trying to retrieve a GridView selected row data..here is my code.. the commented part that gives me the selectedindex works just fine....but the one giving the selected row cell value does't work and there is no error.. The update operation is done successfully...weired. i need to assigned selected row cells values to variables ..do some calculations and then re-assign the result calculation to cell[9]..
The page count is set to 10, when the user checks the checkbox(es), I will need to insert those records in a table. How will I know which row was selected? I found an example (untried) that is designed to loop through and insert the necessary records; but it does not address inserting records based on selecting rows via a checkbox. How do I put everything together.
I have a grid with 5 rows and 5 columns, All containing templetefield(Combobox)I am trying to set the background color of my grid cell(contain combobox) depending upon which item is selected. (again, dependent on item selection, so background color is not permanent). How can i achieve this?
I'm using a gridview rows, in that I'm adding the rows. I need to disable the textboxes based upon the selected value from the dropdownlist (Yes / No). This should be remain same for the previous rows when ever I'm adding new rows.
GridViewDetails uses templatefields. In edittemplate I put a button called "ButtonUpdateAdjustAmount" with OnClick="Update_AdjustAmount" in the EditItemTemplate for the "Amt to be Adj" column. There is also a textbox. My user's should be able to edit the textbox, but I also want the ability to click the button and the textbox populated with the correct calculated value. The formula varies based on the "code" column which is a dropdownlist called "DropListCode".
I am fairly new to asp.net, vb, etc...so forgive my code writing. Eventually I need to also put the same functionality on the insertrow for my gridview. But first wanted to get the edit one working. I am using templatefields for all columns and the FooterTemplate to perform the Insert New Detail Line.
I can get the functionality to work for the first data row and only if I take out the If code.SelectedValue = ... line and leave 1 static formula. However that isn't going to work. If DropListCode.SelectedValue is DNR then AdjAmt should be ((q_ordered - q_received) * cost). If DropListCode. SelectedValue is OV then AdjAmt should be (RKNumber * cost). If DropListCode.SelectedValue is NB the AdjAmt should be ((q_received - q_ordered) * cost). If DropListCode.SelectedValue is DAM then AdjAmt should be (RKNumber * cost)
i have a button in gridview whose command name is "hold" i want when i click n hold button of first row then the whole row values will be transfererd to default2.aspx ...
and if i click the hold button of gridview second row then the second row value will be transferred to Default2.aspx ,,how to do that ?
i m using that ...but it always transfer the 1st row value even i select first last or middle row ..in gridview ....
I have a gridview in webform and a panel1 which I used as a modalpopup control. I wanna show panel as modalpopup per row item select using commandrow of gridview ...
There are two controls inside panel1; literal1 and literal2
I want when the item in the gridview is selected by user then panel 1 shows as modalpopup which displays the records from gridview in panel 1 controls i.e literal1 , literal2
I want to retrieve the selected row item from gridview to modal popup panel1 control..
Suppose I have a e-shop web app. I have a product categories table in my database that populates a gridview using sqldatasource.
I want to be able to click on the select hyperlink on a row and use that event to populate ANOTHER gridview based on the ID of the product category that is clicked. E.g say the 'CDs' row is clicked, another gridview shows all the different CDs.
As a result, I need the select(sql) statement for the second table to be dynamic based on what the user clicks.
i am having gridview with two columns.one column contains checkboxes and another column contains Name.i have given UserId to DataKeyNames in gridview.Now i will check some checkboxes in gridview and click on button GetData. whenver i click on button GetData i need to get datakey values of all the gridview rows whatever checked in gridview using JQUERY
I need to retrieve data based on 3 different selections(current year, 5 years, 10 years). If the user select current year, then I need to pull data with the most up to date year, if the user selects 5 years, then I need to pull data for 5 years from the most up to date year in database. I am trying to accomplish this in sql due to using object DataTables in asp.net 3.5. I am able to do this with separate queries but I need to accomplish this with one query. I was going to use CASE statements but not really sure if I am approaching this correctly.
I'm trying to make a dropdown list with data available based on the users login name. Heres what I have as my SQL Query in the SQLDataSource:
SELECT Client_Name, Client_ID FROM Client WHERE (Client_Name LIKE '%@Client_Name%')
So say if the login username is "User1" but the database client name is "User1 Steel" I want the dropdownlist to pull "User1 Steel" as the display and Client_ID as the value from the dropdown list.
I have a listview that is retrieving some values from a database and showing them. The information are; product name, price, etc. At the end of each row, I have a textbox and a button. Within the textbox the user is able to insert how many items he wants of that particular item and by clicking the button I want the value from the textbox retrieved. It may be relevant to mention that with the button is a event attached (OnClick) which is where I want the value of the textbox to be retrieved. The part that is giving me problem is retrieving the textbox value for that specific row when the button is clicked.
I'm trying to retrieve the value of the "ListName" field that was clicked in the repeater but I'm getting null ("") in "ListTitle", please could someone correct my code:
Protected Sub repTriggers_ItemCommand(ByVal sender As Object, ByVal e As RepeaterCommandEventArgs) Dim ListTitle As String If e.CommandName = "trigger" Then ListTitle = CType(e.Item.FindControl("lnkTrigger"), LinkButton).Text
I am trying to retrieve Detailsview records filtered by dropdownlist which is populated within Detailsview template.
not sure if this is possible but,
i have three cascading dropdownlists within the detailsview and want to set the third dropdownlist value and dependant dropdownlist values according to retrieved record.
at moment they cascade values independant of what record set is retrieved in detailsview and obtain there parameter from selected dropdownlist in pagebehind.
below is select statement bound to Detailsview and itemtemplate for third Dropdownlist control
I have two gridviews on same page - If a record is selected in Gridview1, I need to unselect a record (if one is selected) in Gridview2 - and vice-versa.