473,473 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

textboxes binding in gridview...

1 New Member
hi friends
Please solve this issue.

I have a gridview with a label and 2 textboxes as given below.but when am trying to update the textbox value its not detecting and not updating the value.

Please find the code given below for gridview rowdatabound and gridview row updating. its not at all detecting the textboxes id.
Expand|Select|Wrap|Line Numbers
  1. --------------------------------------------------------------------------------------------------------------
  2.    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
  3.              AllowPaging="True" AllowSorting="True" 
  4.            PageSize="5"  DataKeyNames="Driver_Number"
  5.         OnRowDataBound="GridView1_RowDataBound" 
  6.         OnRowEditing="GridView1_RowEditing" OnRowCancelingEdit="GridView1_RowCancelingEdit"
  7.         OnRowUpdating="GridView1_RowUpdating" OnRowCommand="GridView1_RowCommand"  GridLines="Both" 
  8.         Height="146px" onpageindexchanging="GridView1_PageIndexChanging"   
  9.            onsorting="GridView1_Sorting" Width="897px"      BackColor="#FFFEE5" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"
  10.                    Font-Names="Verdana"  Font-Size="0.9em" ForeColor="#FFB300"  Font-Bold="True">
  11.             <HeaderStyle BackColor="#FFFEE5" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px"
  12.                    Font-Names="Verdana"  Font-Size="0.9em" ForeColor="#FFB300"  Font-Bold="True"/>
  13.  
  14.                <SelectedRowStyle BackColor= "#FFB300" ForeColor="Blue" Font-Names="Arial" Font-Size="11px" />
  15.  
  16.                 <PagerStyle  ForeColor="navy" BackColor="#FFB300" Font-Names="Arial" Font-Size="11px" />
  17.                 <RowStyle Font-Names="verdana" Font-Size="9px" ForeColor="white"  BackColor="#FFB300" />
  18.                 <FooterStyle   BackColor="#FFFEE5" Font-Bold="True" ForeColor="White" />
  19.                 <EditRowStyle  ForeColor="#FFB300" BackColor="#FFFEE5" />
  20.  
  21.                   <Columns>
  22.                   <asp:TemplateField HeaderText="Driver_Number" Visible="false" SortExpression="Driver_Number">
  23.                     <ItemTemplate>
  24.                         <asp:Label ID="lblgrdbmid" runat="server" Text='<%# Bind("Driver_Number") %>'></asp:Label>
  25.                     </ItemTemplate>
  26.                     <EditItemTemplate>
  27.                          <asp:Label ID="lblgrdbmid" runat="server" Text='<%# Bind("Driver_Number") %>'></asp:Label>
  28.                     </EditItemTemplate>
  29.                 </asp:TemplateField>
  30.  
  31.                   <asp:TemplateField HeaderText="Driver" Visible="false"> 
  32.     <EditItemTemplate> 
  33.         <asp:DropDownList ID="cbogrddriver" runat="server"  AutoPostBack="true" >
  34.  
  35.          </asp:DropDownList> 
  36.    </EditItemTemplate> 
  37.     <ItemTemplate> 
  38.         <asp:Label ID="lblgrddriver1" runat="server" Text='<%# Eval("Driver") %>'></asp:Label> 
  39. </ItemTemplate> 
  40.  
  41. </asp:TemplateField> 
  42.                   <asp:TemplateField HeaderText="Driver Category"> 
  43.                      <EditItemTemplate> 
  44.               <asp:TextBox ID="txtgrdcategory" runat="server" Text='<%# Bind("Driver_category") %>'></asp:TextBox> 
  45.             </EditItemTemplate> 
  46.                      <ItemTemplate> 
  47.               <asp:Label ID="lblgrdcategory" runat="server" Text='<%# Eval("Driver_category") %>'></asp:Label> 
  48.             </ItemTemplate> 
  49.                    </asp:TemplateField> 
  50.                   <asp:TemplateField HeaderText="Driver"> 
  51.                      <EditItemTemplate> 
  52.               <asp:TextBox ID="txtgrddriver" runat="server" Text='<%# Bind("Driver") %>'></asp:TextBox> 
  53.             </EditItemTemplate> 
  54.                      <ItemTemplate> 
  55.               <asp:Label ID="lblgrddriver" runat="server" Text='<%# Eval("Driver") %>'></asp:Label> 
  56.             </ItemTemplate> 
  57.                    </asp:TemplateField> 
  58.  
  59.                    <asp:TemplateField HeaderText="Edit" ShowHeader="False"> 
  60.         <EditItemTemplate> 
  61.   <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="false" CommandName="Update" CommandArgument='<%# Bind("Driver_category") %>' Text="Update"></asp:LinkButton> 
  62.   <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="false" CommandName="Cancel" CommandArgument='<%# Bind("Driver_category") %>' Text="Cancel"></asp:LinkButton> 
  63. </EditItemTemplate> 
  64.  
  65.         <ItemTemplate> 
  66.   <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandArgument='<%# Bind("Driver_category") %>' CommandName="Edit" Text="Edit"></asp:LinkButton> 
  67. </ItemTemplate> 
  68.     </asp:TemplateField> 
  69.   <%--<asp:CommandField HeaderText="Delete" ShowDeleteButton="True" ShowHeader="True" />--%> 
  70.  
  71.  
  72.  
  73.               </Columns>
  74.         </asp:GridView>
  75.  
  76. --------------------------------------------------------------------------------------------------------------
  77.  
  78.  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
  79.     {
  80.         if (e.Row.RowType == DataControlRowType.DataRow)
  81.         {
  82.             Label lblgrdbmid = (Label)e.Row.FindControl("lblgrdbmid");
  83.  
  84.             TextBox txtgrdcategory = (TextBox)e.Row.FindControl("txtgrdcategory");
  85.             TextBox txtgrddriver = (TextBox)e.Row.FindControl("txtgrddriver");
  86.             DataTable dt = new DataTable();
  87.             dt = GridDataSource();
  88.             lblgrdbmid.Text = dt.Rows[0].ItemArray[0].ToString();
  89.  
  90.  
  91.             txtgrdcategory.Text = e.Row.Cells[1].Text;
  92.             txtgrddriver.Text = e.Row.Cells[2].Text;
  93.  
  94.  
  95.         }
  96.  
  97.  
  98.  
  99.  
  100.     }
  101.  
  102. this is code for row updating
  103.  
  104.  protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
  105.     {
  106.         Label lblgrdbmid = (Label)GridView1.Rows[GridView1.EditIndex].FindControl("lblgrdbmid");
  107.         GridView1.EditIndex = -1;
  108.         string sample;
  109.         TextBox txtgrdcategory = (TextBox)GridView1.Rows[GridView1.EditIndex].FindControl("txtgrdcategory");
  110.         TextBox txtgrddriver = (TextBox)GridView1.Rows[GridView1.EditIndex].FindControl("txtgrddriver");
  111.         sample = lblgrdbmid.Text;
  112.         DriversInfooBal pbal = new DriversInfooBal();
  113.         DriversBO pbo = new DriversBO();
  114.         pbo.Drivernumber = Convert.ToInt32(lblgrdbmid.Text);
  115.         pbo.StrDriverCategory = txtgrdcategory.Text;
  116.         pbo.StrDriver = txtgrddriver.Text;
  117.  
  118.         pbal.updatedrivers(pbo);
  119.         GridView1.EditIndex = -1;
  120.         BindGrid();
  121.  
  122.  
  123.         //mbo.Processid = Convert.ToInt32(processid);
  124.  
  125.  
  126.  
  127.     }
  128. --------------------------------------------------------------------------------------------------------------
can any one please help me whats wrong here.

Please find the screenshot attached for error

thanks alot in advance

kiran
Attached Files
File Type: zip error.zip (162.0 KB, 70 views)
Apr 12 '11 #1
0 1133

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: rob | last post by:
Here is my scenario: One of my aspx pages has a CheckBoxList (Item1, Item2) and a GridView. Then I have a database that has the columns Item1 and Item2 (among others) with the data type bit....
5
by: sck10 | last post by:
Hello, I have a GridView that is using the following to connect to a SQL Server 2000 stored procedure: <asp:SqlDataSource ID="dsWebDocList" SelectCommand="sp_web_WebDocument"...
0
by: nalbayo | last post by:
First Error Message is like this ObjectDataSource 'ObjectDataSource1' could not find a non-generic method 'Update' that has parameters: BoardManagerId, BoardName, Description, IsForAdmin,...
0
by: Sobin Thomas | last post by:
Hi All, How can I bind the Gridview control to Sql Datasource control on a button click(I see majority of the articles binding datasource at page load) I need to enable the paging and sorting of...
1
by: Sobin Thomas | last post by:
Hi All, How can I bind the Gridview control to Sql Datasource control on a button click(I see majority of the articles binding datasource at page load) I need to enable the paging and sorting of...
1
by: pankajprakash | last post by:
Hi I have an asp.net gridview control. I have used pagging but when I click on grid for pagging it shows the following error Error: A Runtime Error has occurred.Do you wish to Debug? Line: 4723...
1
by: vineetbindal | last post by:
Hi all, I have a datagrid and detailsview. when a user selects a row in datagrid onSelectedIndexchanged is fired and Detailsview comes into picture. I want to display the data of the selected row...
0
by: sbandalli | last post by:
Hi, I have a datagridview1, which has a comboboxcolumn categoryname(which is binded to a database table Category ) listCol.DataSource = cDS.Tables; datagridview1 also has two textbox...
0
by: finie | last post by:
Hi, I'm using Linq to bind a gridview and when I debug I get this exception: "Input string was not in a correct format." this function loads with the Form private void DGVWCcode_Changed() ...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.