user1986144
user1986144

Reputation: 105

gridview with textboxes

i have a GridView with TextBoxes as templelates. now i'm able to insert into the Database. I have a Checkbox as a templet in the gridview so when i check the checkbox the values in the respective row will been inserted into the DB,now i want to Display the Database Values in the same GridView for Update purpose. which i'm not able to do so can anyone please help me

this is my C# Code

SqlCommand search2 = new SqlCommand("select * from OtherCostData", con);
SqlDataAdapter da = new SqlDataAdapter(search2);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();

i only get customer name retrieved the rest will be empty

Upvotes: 0

Views: 361

Answers (1)

Fernando
Fernando

Reputation: 104

If I understood you, what you need to do to fill your gridview's textbox is:

<TemplateField>
  <ItemTemplate>
    <asp:TextBox runat="server" id="txtGrid1" Text='<%#DataBinder.Eval(Container.DataItem, "YourColumnName")%>'/>
  </ItemTemplate>
</TemplateField>

I didn't understand if you are able to save your textbox informations on database. If you're not, please let me know, so I'll try to help you.

Best regards.

Upvotes: 1

Related Questions