I have a grid view that contain many fields, here I am retrieving data from XML file and want to take one more column from the table also. how can i take that from the table.
This is the below code I have tried to retrieve data from XML file.
CODE BEHIND
protected void btnviewdata_Click(object sender, EventArgs e)
{
GridView1.Visible = true;
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=TNVKP_8;Integrated Security=True");
con.Open();
DataSet reportData = new DataSet();
reportData.ReadXml(Server.MapPath("XMLFILENAME.xml"));
GridView2.DataSource = reportData;
GridView2.DataBind();
con.Close();
}
ASPX code
<asp:GridView ID="GridView1" runat="server" Width="96%" PageSize="10" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Select">
<ItemTemplate>
<asp:CheckBox ID="chkbox" runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="TALLY_REC_ID_CODE" HeaderText="Tally_No" />
<asp:BoundField DataField="CLUSTER_ID" HeaderText="Cluster_ID"/>
<asp:BoundField DataField="UNIT_TYPE" HeaderText="Unit_Type" />
<asp:BoundField DataField="VPRC_ID" HeaderText="VPRC_ID" />
<asp:BoundField DataField="SHG_ID" HeaderText="SHG_ID" />
<asp:BoundField DataField="PIP_NO" HeaderText="Pip_No" />
<asp:BoundField DataField="NAME_OF_THE_MEMBER" HeaderText="Member_Name" />
<asp:BoundField DataField="TYPE_OF_LOAN" HeaderText="Type_of_Loan" />
<asp:BoundField DataField="PRINCIPAL" HeaderText="Principal" />
<asp:BoundField DataField="INTEREST" HeaderText="Interest" />
<asp:TemplateField HeaderText="PipNo.">
<ItemTemplate>
<asp:Label ID="PIPCODE" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Remark">
<ItemTemplate>
<asp:Label ID="lblremark" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Here in this
PIPCODE
label I want take data from the sql server.
If XML
pipno
equal my table
pipno
then I want to retrieve the equivalent code for the
pipno
.
And how can I write the query to select the
pipcode
from the table because I want to take the
pipno
from XML and match with SQL then I want to select the equivalent
pipcode
from table and should view in the last column of grid view.
If
pipcode
is available then remark equal to OK, if
pipno
not available then remark equal to NOT IN DB like that.
Post solution for this.
Thanks in advance.