Click here to Skip to main content
15,906,766 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Recommend Color Picker Pin
Vasudevan Deepak Kumar18-Jul-07 23:00
Vasudevan Deepak Kumar18-Jul-07 23:00 
AnswerRe: Recommend Color Picker Pin
totocaster18-Jul-07 23:32
totocaster18-Jul-07 23:32 
Questionrepots in asp.net Pin
Sonia Gupta18-Jul-07 20:29
Sonia Gupta18-Jul-07 20:29 
AnswerRe: repots in asp.net Pin
Vasudevan Deepak Kumar18-Jul-07 23:03
Vasudevan Deepak Kumar18-Jul-07 23:03 
GeneralRe: repots in asp.net Pin
Sonia Gupta18-Jul-07 23:06
Sonia Gupta18-Jul-07 23:06 
GeneralRe: repots in asp.net Pin
Vasudevan Deepak Kumar18-Jul-07 23:57
Vasudevan Deepak Kumar18-Jul-07 23:57 
AnswerRe: repots in asp.net Pin
ballameharmurali18-Jul-07 23:08
ballameharmurali18-Jul-07 23:08 
QuestionGridView Problem.. Pin
DKalepu18-Jul-07 19:58
DKalepu18-Jul-07 19:58 
Hi Everyone,

I have 4 columns GridView.. One is BoundField This column is binded to Sno field from my Access Datasource.. 2nd, 3rd & 4th columns are TemplateFields (PartNo, Manufacturer, Qunatity) .. In this Template Fields, I have textboxes./.

Now, Below this Gridview i hv a Button (btnSubmit). What I am trying to do is when user enters values in to textboxes & click on Submit button, all the values should get update in the database..

To achieve this, i have written the following code:
<asp:GridView ID="myGridView1" runat="server" Width="483px" CellPadding="4" ForeColor="#333333" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" OnSelectedIndexChanged="myGridView1_SelectedIndexChanged">
<Columns>
<asp:BoundField DataField="Sno" HeaderText="SNo" SortExpression="Sno"/>

<asp:TemplateField HeaderText="PartNo">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtPartNo">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Manufacturer">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtMfg">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Quantity">
<ItemTemplate>
<asp:TextBox runat="server" ID="txtQty">
</asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />

</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/db1.mdb"
SelectCommand="SELECT [Sno] FROM [RfqInfo]" >


____________________________

protected void btnSubmit_Click(object sender, EventArgs e)
{
OleDbConnection myConnection = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\Documents and Settings\\venki\\My Documents\\Visual Studio 2005\\WebSites\\RFQTest\\App_Data\\db1.mdb");
myConnection.Open();

string strQuery = string.Empty;

foreach(GridViewRow dgRow in myGridView1.Rows)
{
string str = ((TextBox)dgRow.FindControl("txtPartNo")).Text.ToString();
string str1 = ((TextBox)dgRow.FindControl("txtMfg")).Text.ToString();
string str2 = ((TextBox)dgRow.FindControl("txtQty")).Text.ToString();


strQuery = "UPDATE [RfqInfo] SET [Partno]= '" + str + "', [mfg] = '" + str1 + "', [qty] = '" + str2 + "'";
}

OleDbCommand cmd = new OleDbCommand(strQuery, myConnection);
cmd.ExecuteNonQuery();


myConnection.Close();
}

now, my problem is when i'm clicking on submit its updating the database with the values of last row in my gridview...Confused | :confused: Cry | :(( i'm really lost here.... Anyone please help me........ Is there any wrong with my code? I have searched throughout the google but couldn't fine one...

Any help would be appreciated........
Thanks in Advance.


AnswerRe: GridView Problem.. Pin
Pallavi Bhoite18-Jul-07 20:39
Pallavi Bhoite18-Jul-07 20:39 
GeneralRe: GridView Problem.. Pin
DKalepu18-Jul-07 21:02
DKalepu18-Jul-07 21:02 
AnswerRe: GridView Problem.. Pin
ballameharmurali18-Jul-07 20:43
ballameharmurali18-Jul-07 20:43 
GeneralRe: GridView Problem.. Pin
DKalepu18-Jul-07 21:11
DKalepu18-Jul-07 21:11 
GeneralRe: GridView Problem.. Pin
ballameharmurali18-Jul-07 23:29
ballameharmurali18-Jul-07 23:29 
GeneralRe: GridView Problem.. Pin
DKalepu18-Jul-07 23:41
DKalepu18-Jul-07 23:41 
AnswerRe: GridView Problem.. Pin
Pallavi Bhoite18-Jul-07 22:19
Pallavi Bhoite18-Jul-07 22:19 
GeneralRe: GridView Problem.. Pin
DKalepu19-Jul-07 2:05
DKalepu19-Jul-07 2:05 
AnswerRe: GridView Problem.. Pin
Hirdesh Shrivastava18-Jul-07 23:29
Hirdesh Shrivastava18-Jul-07 23:29 
GeneralRe: GridView Problem.. Pin
DKalepu18-Jul-07 23:40
DKalepu18-Jul-07 23:40 
GeneralRe: GridView Problem.. Pin
Hirdesh Shrivastava19-Jul-07 0:06
Hirdesh Shrivastava19-Jul-07 0:06 
GeneralRe: GridView Problem.. Pin
DKalepu19-Jul-07 2:04
DKalepu19-Jul-07 2:04 
Questionwhat is App.ico in .net? Pin
vijay_8318-Jul-07 19:47
vijay_8318-Jul-07 19:47 
AnswerRe: what is App.ico in .net? Pin
RepliCrux18-Jul-07 19:53
RepliCrux18-Jul-07 19:53 
AnswerRe: what is App.ico in .net? Pin
Mubashir Javaid18-Jul-07 20:03
Mubashir Javaid18-Jul-07 20:03 
Questiondgresult.SelectedItem.Cells(1).Text Pin
n_gchaitra18-Jul-07 19:38
n_gchaitra18-Jul-07 19:38 
QuestionRe: dgresult.SelectedItem.Cells(1).Text Pin
RepliCrux18-Jul-07 19:48
RepliCrux18-Jul-07 19:48 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.