473,386 Members | 1,791 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

C# and asp.net using gridview? Help

3
i am very newbie of asp.net..

i dont know how to get the value for my update event or display ii, from the textbox in gridview.

code in my html

[HTML] <form id="form1" runat="server">
<div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="Black" GridLines="Vertical" OnSelectedIndexChanged="GridView1_SelectedIndexCha nged" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None" BorderWidth="1px" OnRowCancelingEdit="GridView1_RowCancelingEdit1" OnRowEditing="GridView1_RowEditing1" OnRowUpdating="GridView1_RowUpdating1">
<FooterStyle BackColor="#CCCC99" />
<Columns>
<asp:CommandField HeaderText="Edit" ShowEditButton="True" ShowHeader="True" />
</Columns>
<RowStyle BackColor="#F7F7DE" />
<SelectedRowStyle BackColor="#CE5D5A" Font-Bold="True" ForeColor="White" />
<PagerStyle BackColor="#F7F7DE" ForeColor="Black" HorizontalAlign="Right" />
<HeaderStyle BackColor="#6B696B" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>

</div>

</form>[/HTML]



this one is to change make textbox inside the gridview
Expand|Select|Wrap|Line Numbers
  1. protected void GridView1_RowEditing1(object sender, GridViewEditEventArgs e)
  2.     {
  3.         GridView1.EditIndex = e.NewEditIndex;
  4.         bindS();
  5.     }
Expand|Select|Wrap|Line Numbers
  1.  
  2.   protected void GridView1_RowUpdating1(object sender, GridViewUpdateEventArgs e)
  3. {
  4.        GridViewRow row = GridView1.Rows[e.RowIndex];
  5.             TextBox t = row.FindControl("txtName") as TextBox;
  6.      Response.Write("You change it to " + t.text);
  7. }
  8.  

but it returns null.

i also try this one

TextBox txtName = (TextBox)GridView1.Rows[e.RowIndex].FindControl("txtName");

but still returns null

in my html code i dont make any textbox.

whats wrong with this code? please help me with this... thanks
Jul 20 '08 #1
2 1377
DrBunchman
979 Expert 512MB
Moved to .NET Forum - ASP Forum for Classic ASP only.

Dr B
Jul 21 '08 #2
And where is you txtName? I can't see it - of course it would return null - it doesn't exist.
In your GridView you should have a TemplateField column in which you have the txtName - then your code will work.
Jul 22 '08 #3

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

Similar topics

0
by: ck388 | last post by:
For some reason when I enable the callback feature of the gridview I still get a page refresh, that is it seems like there is a postback that occurs, not a callback which is just supposed to update...
0
by: W. Kacy | last post by:
I am having trouble using XML in an ASP.NET 2.0 webform. Using ASP.NET 2.0 beta 2, I have created a blank web page in a C# website. I have added an XML file (soData.xml), structured as follows: ...
6
by: Nalaka | last post by:
Hi, I have a gridView (grid1), which as a templateColumn. In the template column, I have put in a gridView (grid2) and a ObjectDataSource (objectDataSource2). Question is... How to I pass the...
3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
1
by: Barry L. Camp | last post by:
Hi all, Wondering if someone can help with a nagging problem I am having using a GridView and an ObjectDataSource. I have a simple situation where I am trying to delete a row from a table, but...
0
by: LiamLiamLiam | last post by:
G'day all. I having a problem with my formview. I'll ty to explain my situation as best as i can. I have a page with a search field at the top which is just a simple asp:textbox. Below that i...
2
by: William Youngman | last post by:
We are developing an application that presents data to the user in a gridview and we are using the dropdown extender to give the user a SharePoint 2007 type dropdown menu attached to the cells of a...
1
by: sheenaa | last post by:
Hello Members, I m creating my application forms in ASP.Net 2005 C# using the backend SQL Server 2005. What i have used on forms :: ? On my first form i have used some...
2
by: frankiefrank | last post by:
I have been struggling with this issue for some time, hope someone here can help out. After facing the issue (will describe it soon) in a solution with Ajax and a Master Page I decided to try it...
4
ollyb303
by: ollyb303 | last post by:
Hi, wasn't sure whether I should post this under .net, IIS or access, but I've plumped for .net! I have a problem with an asp.net website which I am hosting on a windows server 2003 under IIS...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.