To refer to one field of Gridview

Hi,
I want to also show one Dropdownlist to Currency code below. what should be adjusted? How to refer to the value of Currency code, from code-behind?

    <asp:GridView ID="GridView1" runat="server"  Width = "550px"
    AutoGenerateColumns = "false" Font-Names = "Arial"
    Font-Size = "11pt" AlternatingRowStyle-BackColor = "#C2D69B"
    HeaderStyle-BackColor = "green" AllowPaging ="true"  
    ShowFooter = "true" OnPageIndexChanging="GridView1_PageIndexChanging"
    OnRowCancelingEdit="GridView1_RowCancelingEdit" OnRowEditing="GridView1_RowEditing"
    OnRowUpdating="GridView1_RowUpdating" PageSize = "10" OnRowDeleting="GridView1_RowDeleting" OnRowDataBound="GridView1_RowDataBound">
    <Columns>
    <asp:TemplateField HeaderText="Currency">
        <ItemTemplate>
            <asp:DropDownList ID="ddl" OnSelectedIndexChanged="ddl_IndexChanged" AutoPostBack="true" runat="server">
            </asp:DropDownList>
        </ItemTemplate>
        <EditItemTemplate>
            <asp:DropDownList ID="ddl2" OnSelectedIndexChanged="ddl_IndexChanged" AutoPostBack="true" runat="server">
            </asp:DropDownList>
        </EditItemTemplate>
        <FooterTemplate>
            <asp:DropDownList ID="ddl3" OnSelectedIndexChanged="ddl_IndexChanged" AutoPostBack="true" runat="server">
            </asp:DropDownList>
        </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField Visible="false">
        <ItemTemplate>
            <asp:TextBox id="tb_currency_code" runat="server" Text='<%# Eval("currency_code") %>' Visible="false" />
        </ItemTemplate>
        <EditItemTemplate>
            <asp:TextBox id="TextBox2" runat="server" Text='<%# Eval("currency_code") %>' Visible="false" />
        </EditItemTemplate>
        <FooterTemplate>
            <asp:TextBox id="TextBox5" runat="server" Text='<%# Eval("currency_code") %>' Visible="false" />
        </FooterTemplate>
    </asp:TemplateField>
    <asp:TemplateField ItemStyle-Width = "150px"  HeaderText = "Saving Rate">
        <ItemTemplate>
            <asp:Label ID="curr_rate" runat="server"
                Text='<%# Eval("Currency_rate")%>'>
            </asp:Label>
        </ItemTemplate>
        <EditItemTemplate>
            <asp:Label ID="Label1" runat="server"
                Text='<%# Eval("Currency_rate")%>' >
            </asp:Label>
        </EditItemTemplate>
        <FooterTemplate>
            <asp:Label ID="Label2" runat="server"
                Text='<%# Eval("Currency_rate")%>' >
            </asp:Label>
        </FooterTemplate>
    </asp:TemplateField>
    ...
LVL 11
HuaMin ChenProblem resolverAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Maheshwar RSoftware DeveloperCommented:
use the below code to get the ddl from grid and then bind the ddl as needed from the database

 foreach (GridViewRow gvr in GridView1.Rows)
                    {
     DropDownList ddl = (DropDownList)gvr.Cells[0].FindControl("ddl");
//write the bind code for currency here
}

Open in new window

0
HuaMin ChenProblem resolverAuthor Commented:
Thanks. How to refer to that field, within this?

protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
...

Open in new window

0
Maheshwar RSoftware DeveloperCommented:
try the following

 DropDownList ddl = (DropDownList)GridView1.SelectedRow.Cells[0].FindControl("ddl");
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

HuaMin ChenProblem resolverAuthor Commented:
But how to retrieve the value of "Currency code" within the above event?
0
Maheshwar RSoftware DeveloperCommented:
after that line add the following line

ddl.Text
0
HuaMin ChenProblem resolverAuthor Commented:
Many thanks. I deploy the project and get the following, when going to the page
Server Error
Internet Information Services 7.5
Error Summary
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Detailed Error Information
Module	IIS Web Core
Notification	BeginRequest
Handler	Not yet determined
Error Code	0x80070003
Config Error	Cannot read configuration file
Config File	\\?\C:\inetpub\VS2012\Start_dev\web.config
Requested URL	http://192.168.168.1:80/Start_dev/Default.aspx
Physical Path	C:\inetpub\VS2012\Start_dev\Default.aspx
Logon Method	Not yet determined
Logon User	Not yet determined
Config Source
   -1: 
    0: 
Links and More Information
This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the event logs may contain more information about what caused this error.
View more information »

Open in new window


why?
0
Maheshwar RSoftware DeveloperCommented:
check your web.config file, seems like there is an error in the file and its not able to read.

Also did you assign the value of "ddl.Text" to a variable ?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.