TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Rajkumar R
NA
183
220.6k
Fill grid view from both XML data and grid data
Dec 7 2011 6:40 AM
i have a grid view that contain many fields, here i m retriving 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 retrive 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 reteive the equivalent code 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 th equivalent pipcode from table and should view in the last column of grid view.
If pipcode is available the remark equal to OK
if pipno not available then remark equal to NOT IN DB like that
post solution for this
Thanks in advance
Reply
Answers (
0
)
How to convert code from C#(2005) to VB.NET(2000)
Connection string for Tandem DB connection through ASP.Net ODBC