Click here to Skip to main content
15,888,239 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all..
i Have a DetailsView Where Default mode is edit with Mysql DataBase
like:
VB
<asp:DetailsView ID="DetailsView" runat="server" DefaultMode="Edit" Width="95%"
                                       BackColor="white" />

While Debugging am getting Details View Like This
name dave
Gender Male
Age 22
Status Active
here I need To update Some Values So that I write something in Every Text box And Click Update Button Here I need Get The Written Values So I used Like
DetailsView1.Rows[0].Cells[1].Text But It returns "" Null Value
so How Can I Get Newly Entered Values
Can Any One Help Me Please
Thanks In Advance
Posted

TextBox tb = DetailsView1.Rows[0].Cells[1].Controls[0] as TextBox;
//tb.Text is your result
 
Share this answer
 
Comments
tulasiram3975 8-Jul-11 5:47am    
Thank You Sir....
How Stupid am!!
My Mind Not Working Properly Due To Heavy Work
Prerak Patel 8-Jul-11 5:50am    
You are welcome.
Take Template Field Like Below

XML
<asp:DetailsView ID="dvCategory" runat="server" AutoGenerateRows="False"
              DataKeyNames="iCategoryID" Width="90%" GridLines="None"
              OnItemInserting="dvCategory_ItemInserting"
              OnItemUpdating="dvCategory_ItemUpdating"
              OnModeChanging="dvCategory_ModeChanging" ondatabound="dvCategory_DataBound" >
             <Fields>
                 <asp:BoundField DataField="iCategoryID" HeaderText="ID" InsertVisible="False" ReadOnly="True" />
                 <asp:TemplateField HeaderText="Name">
                      <EditItemTemplate>
                        <asp:TextBox ID="txtCategoryName" runat="server" Text='<%# Bind("strCategoryName") %>'></asp:TextBox>
                        <asp:RequiredFieldValidator ID="rfvCategoryName" runat="server" ControlToValidate="txtCategoryName"
                        Display="Dynamic" ErrorMessage="Name" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                      </EditItemTemplate>
                      <InsertItemTemplate>
                         <asp:TextBox ID="txtCategoryName" runat="server" Text='<%# Bind("strCategoryName") %>'></asp:TextBox>
                         <asp:RequiredFieldValidator ID="rfvCategoryName" runat="server" ControlToValidate="txtCategoryName"
                          Display="Dynamic" ErrorMessage="Name" SetFocusOnError="True">*</asp:RequiredFieldValidator>
                      </InsertItemTemplate>
                      <ItemTemplate>
                          <asp:Label ID="lblCategoryName" runat="server" Text='<%# Bind("strCategoryName") %>'></asp:Label>
                     </ItemTemplate>
                  </asp:TemplateField>

                 <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
                  </Fields>
              </asp:DetailsView>
 
Share this answer
 
Comments
tulasiram3975 9-Apr-12 6:00am    
Thank you..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900