I have a GridView that is populated with data from an SQL database, very simple. Now I want to replace the values ββin my single column, like this ......
If the value of c04_oprogrs is 1, then display Take in a GridView.
If the value of c04_oprogrs is 2, then display Available in the GridView.
What code changes need to be made to my code to display the new values.
My grid
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Height="281px" Width="940px" Font-Size="X-Small" AllowPaging="True" onpageindexchanging="GridView1_PageIndexChanging"> <Columns> <asp:BoundField DataField="c04_oprogrs" HeaderText="Order Progress" SortExpression="c04_oprogrs" /> <asp:BoundField DataField="c04_orderno" HeaderText="Order No." SortExpression="c04_orderno" /> <asp:BoundField DataField="c04_orddate" HeaderText="Date of Order" SortExpression="c04_orddate" DataFormatString="{0:d/MM/yyyy}" /> <asp:BoundField DataField="c04_ordval" HeaderText="Order Value" SortExpression="c04_ordval" DataFormatString="{0:R#,###,###.00}" /> <asp:BoundField DataField="c04_delval" HeaderText="Delivered Value" SortExpression="c04_delval" DataFormatString="{0:R#,###,###.00}" /> <asp:BoundField DataField="c04_invval" HeaderText="Invoice Value" SortExpression="c04_invval" DataFormatString="{0:R#,###,###.00}" /> <asp:BoundField DataField="c04_orddesc" HeaderText="Order Description" SortExpression="c04_orddesc" > <ControlStyle Width="300px" /> </asp:BoundField> </Columns> </asp:GridView>
Loading my page
SqlConnection myConnection; DataSet dataSet = new DataSet(); SqlDataAdapter adapter; //making my connection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["SAMRASConnectionString"].ConnectionString); adapter = new SqlDataAdapter("Select TOP 40 c04_credno, c04_orderno, c04_orddate, c04_ordval, c04_delval, c04_invval, c04_oprogrs, c04_orddesc FROM C04ORDS WHERE c04_credno = '" + Session["CreditorNumber"] + "'AND c04_oprogrs <> 9 ORDER BY c04_orddate DESC", myConnection); adapter.Fill(dataSet, "MyData"); GridView1.DataSource = dataSet; Session["DataSource"] = dataSet; GridView1.DataBind();
Etienne
EDIT:
MY FINAL DECISION
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) {
source share