Change DataGrid cell value in VB6 - datagrid

Good day guys.
I am developing VB6 project and I know it's old but thats the standard in Japan. I am not into datagrid expert guy that can tweak everything inside of it but my problem is that I have data to be displayed in datagridview which they want to change the cell value if the data having value for example :
FRUIT | QTY
apple | 1
orange | 2
So if apple having QTY value of "1" I want to change it into something like star or circle value.
It's a datagrid control(databound) in WinForm App. My datasource is sql server.
Thank you guys in advance.

The technology (VB6) is indeed very old; you can try something like
Sub AddSymbol()
For i = 1 To DataGrid1.Rows
If DataGrid1.Item(i, 2) = 1 Then DataGrid1.Item(i, 2) = "*"
Next i
End Sub
where quantity is stored in the second column of DataGrid1 control. Hope this may help.

Related

multiple choice quiz- adding up score

so my intention is to build a quiz on visual basic it is a multiple choice quiz,
i am using 4 buttons as the answer so what I want to do is if they click the correct answer it adds 1 to the score but if they click the wrong button it doesn't add anything. I'm going to be using like 5 questions per level and there are 5 levels and I am going to display the total after they have answered on separate form at the end. Does anyone know how I would go about doing all this
First of all, on the questions if you've got it advancing to the next stage I imagine you have a method to determine whether the answer that they are inputting is correct? If I am right, then this should be pretty simple to do.
You want to declare total score as a variable, this will store the overall score.
To do this you can go like...
Dim totalscore As Integer
totalscore = "0"
It is important to set the score on the startup.
Now on the process when you click the correct answer you want to just put a simple statement like
totalscore = totalscore + 1
This'll add 1 to the score when they advance. You can implement this anyway you like for example you can say
If correctanswer.checked = true then
totalscore = totalscore + 1
End If
Let me know how you get on

Create dynamic table with Add Update Delete options

I am new to asp.net so I dont know the best approach to deal following scenario.
I want to create a dynamic table like following which perform Add Update Delete -
Player SmartGoal Decision Thinking
ABC 10 10 9
PQR 7 9 10
next time table would be -
Player Decision Learning
ABC 10 5
PQR 7 9
I am using c#
I think we have to create databinding to control and control programmatically.
What control should I use?
What is the best approach for this scenario ?
You should use GridView control.
Or for more advanced and neat stuff you probably want to try [telerik][2] controls (not free)
This all needs to be driven by a database.
Just search for two tutorials to get started: how to create a sql server database, and how to use GridView control.
if you need to display hierachical data you can try to use ListView control:
As per my understanding you are fetching data from DB and binding to some control. I thinks the best approach for this to get the dataset from Database and bind to the gridview. You can find many example on net for bind sql datset on internet. Please let me know for any further clarification.
Thanks
Uttam
One Approach is:
Get the column name from Database and add them to a Label.
like lblColumn1.Text = colname1 & so on. Use loop.
Next step is to get the entries and add them to textbox/label again.
similar coding.
Forget not to use Try/catch for exceptions. You never know which column in DB isn't having values or null values.
For Edit/Add/Delete.
Add buttons before each each record to delete and edit
add button should be on top.
**No need to databind or anything like that.
**Basic knowledge of asp will do.
As per my understanding you are fetching data from DB and binding to some control. I thinks the best approach for this to get the dataset from Database and bind to the gridview. You can find many example on net for bind sql datset on internet. Please let me know for any further clarification.
If possible provide some more details. Here i am placing one example where dynamic table is created at runtime
Private Sub BuildSTX9Header()
Dim dtTemp As New DataTable
Dim dr As DataRow
dtTemp.Columns.Add(Me.GetLocalResourceObject("STXLocationID").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("SKU").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("SKU Description").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("MED").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("MSFSupportedProduct").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("Infor365 Product").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("SupportPlan").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("No.Users").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("SAM").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("LocationName").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("SerialNumber").ToString)
dtTemp.Columns.Add(Me.GetLocalResourceObject("Phone").ToString)
For i = 0 To dsData.Tables(0).Rows.Count - 1
dr = dtTemp.NewRow()
dr(0) = dsData.Tables(0).Rows(i)(2)
dr(1) = dsData.Tables(0).Rows(i)(3)
dr(2) = dsData.Tables(0).Rows(i)(4)
dr(3) = dsData.Tables(0).Rows(i)(5)
dr(4) = dsData.Tables(0).Rows(i)(6)
dr(5) = dsData.Tables(0).Rows(i)(7)
dr(6) = dsData.Tables(0).Rows(i)(8)
dr(7) = dsData.Tables(0).Rows(i)(9)
dr(8) = dsData.Tables(0).Rows(i)(10)
dr(9) = dsData.Tables(0).Rows(i)(11)
dr(10) = dsData.Tables(0).Rows(i)(12)
dr(11) = dsData.Tables(0).Rows(i)(13)
dtTemp.Rows.Add(dr)
Next
gvLoadRuntime.DataSource = dtTemp
gvLoadRuntime.DataBind()
ViewState("RowCount") = dtTemp.Rows.Count
ViewState("dvRuntimeData") = dtTemp
Thanks
Uttam

Accessing Data cell value in Gridview

I have a gridview containing details of ticket types and prices which the gridview gets from the database. In my Default.aspx.vb file I want to access the price value for a specific ticket but I cant figure out how to do it. My GridView looks like this:
Ticket Prices
price_ID type peak_offpeak cost
1 Adult peak 10.00
2 Adult offpeak 5.00
Any help would be much appreciated, thank you for your time
J
Ah I discovered this is what I needed incase anybody else has the same question:
Dim row As GridViewRow = GridView1.Rows(1)
adult_price = row.Cells(3).Text
J

How to update the particular column values of gridview on specific dates using vb.net?

I have column in database
ID From To s1from s2to s2price fare
1 Delhi Manali 17-Dec-2010 19-Dec-2010 $900 $600
2 USA Canada 18-Dec-2010 20-Dec-2010 $500 $800
3 Newyork salinas 19-Dec-2010 22-Dec-2010 $760 $1000
I want when any user search For: Delhi to Manali on between 17-Dec-2010 to 19-Dec-2010 then the price would be automatically changes to $900 in gridview else the default price wold be displayed in fare is $600 if he search for DelHi to Manali after 19-Dec-2010.
I m confused how to implement this logic ... using vb.net ...
If I understand correctly, I think you could do using this query:
SELECT DateSpecificFare = CASE WHEN s1from <= inDate AND s2to >= inDate THEN s2price ELSE fare END FROM YourTable WHERE From = inFrom AND To = inTo
Where inDate, inFrom and inTo would be the parameters the user selects.
Your previous query also made it look like you might not know how to make the calls to the database so if that's the case, look at SqlCommand.ExecuteScalar which includes some sample code showing you how to do that. Or if you need to return more than one column and/or record from your table, look at SqlCommand.ExecuteReader instead.
Btw, you should really edit your previous question rather than create a new one, otherwise it might get closed as a duplicate. But in this case I'll answer this one rather than the previous ones since this is the one with the best question.

Databound Checkbox list with textboxes in a webform

I'm having trouble coming up with a solution for the following problem and i was wondering if someone here would help me out.
I need to pull a list of supplies from a db table and list them along with two textboxes (one for quantity, and another for manufacturer)
so the list would look something like this.
checkbox for supply 1 | Quantity | Manufacturer
checkbox for supply 2 | Quantity | Manufacturer
..
I also need to store all of the checked items in a db table.
I'm not sure how i should go about doing this. I've heard some talk about a repeater control being useful but i've not come across any examples that do this type of thing.
Thanks in advance
I've used the ListView for things like this, but Repeater probably woudl work too; simply create the ItemTemplate with these controls. On a button click, you can loop through the ListView.Items collection, using FindControl to find the checkbox, and if checked, get the textbox values.
It's pretty easy to setup.

Resources