Results 1 to 3 of 3

Thread: [1.0/1.1] i canot get values from datagrid

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    11

    [1.0/1.1] i canot get values from datagrid

    I am populating grid dynamically on page load .it contains webcontrols like dropdown and labels.now i am trying to get values from the grid but i am unable to get the values.

    foreach(DataGridItem objDataGridItem in dgPrice.Items )
    {

    DropDownList objDropDownlist = (DropDownList)(objDataGridItem.Cells[1].Controls[1]);
    Degree =Degree+ ((DropDownList)objDataGridItem.FindControl("drpQty")).SelectedItem.Text;
    Degree =Degree+objDataGridItem.Cells[1].Text;
    }

    This is bit of my code which shows what i am trying to do.
    Please help ma ASAP

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [1.0/1.1] i canot get values from datagrid

    You've already created objDropDownList, but you're not using it, why?

    Also, step through your code to see whether you're actually able to find the controls you want.

    And when you run this code, what actually happens?

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    11

    Re: [1.0/1.1] i canot get values from datagrid

    have populated a datagrid on page load.The grid contain a bound column and 3 template columns.The template columns contain dropdownlist and labels.i have a button on the page and the action of that button is to get the values from the grid and print it on the label (lblMessage.Text) which is also suitated on the page.Now the problem is when i click the button the information of bound columns is displayed but the information of the template column is invisible.It doesnt gives error but the values are not printed on the label
    my code is

    private void btnAddToCart_Click(object sender, System.EventArgs e)
    {

    string Degree="";

    foreach(DataGridItem objDataGridItem in dgPrice.Items ) {

    Degree =Degree+ ((DropDownList)objDataGridItem.FindControl("drpQty")).SelectedItem.Text;

    Degree =Degree+((Label)objDataGridItem.FindControl("lblSizeInches")).Text;

    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width