Hello frnds,
I have created a datagrid with the following code...... -
-
<asp:datagrid id="DataGrid1" BackColor="#ccccff" BorderColor="black" Width="750" Runat="server" AutoGenerateColumns="False" HeaderStyle-BackColor="#aaaadd" Font-Size="8pt" Font-Name="Verdana" CellSpacing="0" CellPadding="3" ShowFooter="True" GridLines="None" OnItemDataBound="Datagrid1_itemdataBound">
-
<Columns>
-
<asp:TemplateColumn HeaderText="S.No."></asp:TemplateColumn>
-
<asp:TemplateColumn HeaderText="Select">
-
<ItemTemplate>
-
<asp:CheckBox ID="checkbox1" Runat="server" Checked="False"></asp:CheckBox>
-
</ItemTemplate>
-
</asp:TemplateColumn>
-
<asp:BoundColumn HeaderText="BookId" DataField="BookId" Visible="true"></asp:BoundColumn>
-
<asp:BoundColumn HeaderText="CatId" DataField="CatId" Visible="true"></asp:BoundColumn>
-
<asp:BoundColumn HeaderText="Book Name" DataField="Title"></asp:BoundColumn>
-
<asp:BoundColumn HeaderText="Author" DataField="Author"></asp:BoundColumn>
-
<asp:BoundColumn HeaderText="Publisher" DataField="Publisher"></asp:BoundColumn>
-
<asp:BoundColumn HeaderText="Price" DataField="Price" DataFormatString="{0:c}"></asp:BoundColumn>
-
<asp:BoundColumn HeaderText="Quantity" DataField="Quantity"></asp:BoundColumn>
-
<asp:BoundColumn HeaderText="Category" DataField="CatName"></asp:BoundColumn>
-
</Columns>
-
</asp:datagrid>
The datagrid is bind with the database on button click event...... -
sub button1_click(sender as object,e as eventargs)
-
dim book as string
-
dim ctr as integer
-
dim con as sqlconnection
-
'dim cmd as sqlcommand
-
dim da as sqldataadapter
-
dim ds as dataset
-
dim str as string
-
book=txt1.text.toupper()
-
cat=dropdownlist1.selectedvalue
-
-
'response.write(book)
-
ctr=integer.parse(cat)
-
'response.write(ctr.tostring())
-
str="server=WADHWA;user id=sa;pwd=;initial catalog=OnlineShoppingDatabase"
-
con=new SqlConnection(str)
-
con.open()
-
'str="select bookdetails.catid , bookdetails.Title,bookdetails.author,bookdetails.publisher,bookdetails.price,bookdetails.quantity,CategDetails.CatName from bookdetails inner join categDetails on CategDetails.catid= bookdetails.catid where bookdetails.title='" & txt1.text.toupper & "' and CategDetails.catid=" & dropdownlist1.selectedvalue
-
str="select bookdetails.bookId,bookdetails.CatId,bookdetails.Title,bookdetails.author,bookdetails.publisher,bookdetails.price,bookdetails.quantity,CategDetails.CatName from bookdetails inner join categDetails on CategDetails.catid= bookdetails.catid where bookdetails.title like '%" & txt1.text.toupper & "%' and CategDetails.catid=" & dropdownlist1.selectedvalue
-
da=new SqlDataAdapter()
-
da.selectcommand=new SqlCommand()
-
da.selectcommand.connection=con
-
da.selectcommand.commandtext=str
-
ds=new DataSet
-
da.fill(ds)
-
response.write(ds.tables(0).columns.count.tostring())
-
if ds.tables(0).rows.count =0 then
-
' datagrid1.datasource=ds
-
'datagrid1.databind()
-
'response.redirect("webform5.aspx")
-
response.write("No Matches found")
-
else
-
Panel1.visible=true
-
datagrid1.datasource=ds
-
datagrid1.databind()
-
end if
-
con.close()
-
end sub
In this code section,I have used a join query.There are two tables
BookDetails with fields(bookid,c atid,title,auth or,publisher,pr ice,quantity) and CategDetails with fields(catid,ca tname).
Now when i display the total number of columns bind with datagrid is only 6 but it has to bind 8 columns (bookid,catid,t itle,author,pub lisher,price,qu antity,catname respectively),w ith this following code :- -
Response.write(Datagrid1.items.count.tostring)
Please why its happening.is there any miscoded by me ????
1 1266
Can you determine by their contents which columns are not getting bound?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ashish Shridharan |
last post by:
Hi All
I have been trying to add a control to the header cell of
a datagrid on my ASP.NET page. These controls are defined
in the HTML as ASP.NET web controls.
They are being added into the header of the datagrid in
the "ItemDataBound" method of the grid. However, once,
they are added in the grid, i seem to lose the event
handler for the same control. Is there anyone who has
tried this before and knows why this is hapenning ??
|
by: Jeff |
last post by:
IDE: VS 2003 :NET
OS: XP Pro
My app have a form with a tab-control on it. The tab-control have 2
tabpages. One of the tabpages displays a datagrid, and the other tabpage
displays details (order date, name, address etc) about the selected row in
the datagrid...
My problem is when I enter a new record in the details tabpage (saves data
to database), and go back to the datagrid. Only the data from the PM-table
|
by: Steve B. |
last post by:
I have a DataGrid on the left and TextBoxes (TB) on the right. The TB's
reflect the contents of the grid cells.
Sorting of columns (both thru VS and programmatically) work fine except,
when the form/grid first opens up and the grid is immediately sorted the TB
don't reflect the sorted data of the First row of the grid.
Note: Initially the black grid indicator arrow points to the first row. If
the user choses another row and then sorts...
|
by: Dave |
last post by:
Tried posting in the Winform Forum without much luck, so posting here...
After inserting a new data row to a DataTable that is bound to a
datagrid, I am unable to change data in a row that is after the newly
added row without getting bizarre results.
I have added the full code for the test below. Create a project drop
in the code and run. There is nothing crazy about the code. I used
the designer to add the dataset and to do the...
|
by: Jim Heavey |
last post by:
Trying to figure out the technique which should be used
to add rows to a datagrid. I am thinking that I would
want an "Add" button on the footer, but I am not quite
sure how to do that. Is that the best method? Do you
have a sample of how to do this?
| |
by: Richard L Rosenheim |
last post by:
I have a dataset containing a parent table related to a child table. The
child table contains an ID field (which is configured as autonumber in the
datatable), the ID of the parent, plus some addition fields.
I'm able to get the datagrid to be properly populate with only the child
records relating to the specified parent by setting the
..DefaultView.RowFilter property.
Currently, to properly add a new child record, I need to manually...
|
by: Jan Nielsen |
last post by:
Hi all
I'm a former Access developer who would like to implement a many-to-many
relation in about the same way you do in Access: With a subform and a combo
box.
Is it possible to use a combobox in a datagrid?
Any other suggestions/articles on how to implement many-many relations in
the frontend (which of course are 2 one-many relations)?
|
by: p.mc |
last post by:
Hi all,
I'm having major problems with a userControl which contains a datagrid.
My problem concerns data binding.
The Page_Load() procedure calls the DataBind procedure to bind the
datagrid to a DataSet.
If i include an if statement to prevent the data binding from occuring
on a page PostBack in the following way:
|
by: Arpan |
last post by:
Assume that a database table has the following 4 columns - ID, UserID,
Subject & Marks. I am retrieving the records existing in this DB table
& displaying them in a DataGrid like this:
<script runat="server">
Sub Page_Load(obj As Object, ea As EventArgs)
Dim dSet As DataSet
Dim sqlConn As SqlConnection
Dim sqlDapter As SqlDataAdapter
|
by: =?Utf-8?B?Y3JlYXZlczA2MjI=?= |
last post by:
I have a nested datagrid in a xaml file, the parent datagrid loads the vendor
information and the details loads the documents for that vendor in a
datagrid. Everything is working fine until I click in the child datagrid and
then go to the combobox and choose another vendor. When the new vendor is
loaded nothing shows in the datagrid but the itemsource shows the info is
there. Know if I click on the child cell and then click back on the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |